;
//十六进制颜色值域RGB格式颜色值之间的相互转换

//-------------------------------------
//十六进制颜色值的正则表达式
var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
/*RGB颜色转换为16进制*/
String.prototype.colorHex = function(){
    var that = this;
    if(/^(rgb|RGB)/.test(that)){
        var aColor = that.replace(/(?:\(|\)|rgb|RGB)*/g,"").split(",");
        var strHex = "#";
        for(var i=0; i<aColor.length; i++){
            var hex = Number(aColor[i]).toString(16);
            if(hex === "0"){
                hex += hex;
            }
            strHex += hex;
        }
        if(strHex.length !== 7){
            strHex = that;
        }
        return strHex;
    }else if(reg.test(that)){
        var aNum = that.replace(/#/,"").split("");
        if(aNum.length === 6){
            return that;
        }else if(aNum.length === 3){
            var numHex = "#";
            for(var i=0; i<aNum.length; i+=1){
                numHex += (aNum[i]+aNum[i]);
            }
            return numHex;
        }
    }else{
        return that;
    }
};

//-------------------------------------------------

/*16进制颜色转为RGB格式*/
String.prototype.colorRgb = function(){
    var sColor = this.toLowerCase();
    if(sColor && reg.test(sColor)){
        if(sColor.length === 4){
            var sColorNew = "#";
            for(var i=1; i<4; i+=1){
                sColorNew += sColor.slice(i,i+1).concat(sColor.slice(i,i+1));
            }
            sColor = sColorNew;
        }
        //处理六位的颜色值
        var sColorChange = [];
        for(var i=1; i<7; i+=2){
            sColorChange.push(parseInt("0x"+sColor.slice(i,i+2)));
        }
        return "rgb(" + sColorChange.join(",") + ")";
    }else{
        return sColor;
    }
};

var mapstyleJson=[
    {
        "featureType": "water",
        "elementType": "all",
        "stylers": {
            "color": "#0d214fff"
        }
    },
    {
        "featureType": "highway",
        "elementType": "geometry.fill",
        "stylers": {
            "color": "#041133ff"
        }
    },
    {
        "featureType": "highway",
        "elementType": "geometry.stroke",
        "stylers": {
            "color": "#357fc5ff"
        }
    },
    {
        "featureType": "arterial",
        "elementType": "geometry.fill",
        "stylers": {
            "color": "#041133ff"
        }
    },
    {
        "featureType": "arterial",
        "elementType": "geometry.stroke",
        "stylers": {
            "color": "#0b3d51ff"
        }
    },
    {
        "featureType": "local",
        "elementType": "geometry",
        "stylers": {
            "color": "#04153aff"
        }
    },
    {
        "featureType": "land",
        "elementType": "all",
        "stylers": {
            "color": "#204b7fff"
        }
    },
    {
        "featureType": "railway",
        "elementType": "geometry.fill",
        "stylers": {
            "color": "#000000"
        }
    },
    {
        "featureType": "railway",
        "elementType": "geometry.stroke",
        "stylers": {
            "color": "#226491ff"
        }
    },
    {
        "featureType": "subway",
        "elementType": "geometry",
        "stylers": {
            "lightness": -12
        }
    },
    {
        "featureType": "building",
        "elementType": "geometry.fill",
        "stylers": {
            "color": "#000000"
        }
    },
    {
        "featureType": "all",
        "elementType": "labels.text.fill",
        "stylers": {
            "color": "#857f7f"
        }
    },
    {
        "featureType": "all",
        "elementType": "labels.text.stroke",
        "stylers": {
            "color": "#000000"
        }
    },
    {
        "featureType": "building",
        "elementType": "geometry",
        "stylers": {
            "color": "#022338"
        }
    },
    {
        "featureType": "green",
        "elementType": "geometry",
        "stylers": {
            "color": "#082b54ff"
        }
    },
    {
        "featureType": "boundary",
        "elementType": "all",
        "stylers": {
            "color": "#1e1c1c"
        }
    },
    {
        "featureType": "manmade",
        "elementType": "geometry",
        "stylers": {
            "color": "#022338ff"
        }
    },
    {
        "featureType": "poi",
        "elementType": "all",
        "stylers": {
            "visibility": "off"
        }
    },
    {
        "featureType": "all",
        "elementType": "labels.icon",
        "stylers": {
            "visibility": "off"
        }
    },
    {
        "featureType": "land",
        "elementType": "labels.text.fill",
        "stylers": {
            "color": "#ff00ffff",
            "visibility": "on"
        }
    },
    {
        "featureType": "subway",
        "elementType": "geometry",
        "stylers": {
            "color": "#64abcfff",
            "lightness": -32
        }
    },
    {
        "featureType": "districtlabel",
        "elementType": "labels.text.fill",
        "stylers": {
            "color": "#dce6fdff"
        }
    },
    {
        "featureType": "road",
        "elementType": "labels.text.fill",
        "stylers": {
            "color": "#dce6fdff"
        }
    },
    {
        "featureType": "districtlabel",
        "elementType": "labels.text.stroke",
        "stylers": {
            "color": "#16387f00"
        }
    },
    {
        "featureType": "road",
        "elementType": "labels.text.stroke",
        "stylers": {
            "color": "#16387f9e"
        }
    },
    {
        "featureType": "building",
        "elementType": "all",
        "stylers": {
            "color": "#204b7fff"
        }
    },
    {
        "featureType": "manmade",
        "elementType": "geometry.fill",
        "stylers": {
            "color": "#204b7fff"
        }
    },
    {
        "featureType": "manmade",
        "elementType": "labels.text.fill",
        "stylers": {
            "color": "#dce6fdff"
        }
    },
    {
        "featureType": "manmade",
        "elementType": "labels.text.stroke",
        "stylers": {
            "color": "#16387f00"
        }
    },
    {
        "featureType": "local",
        "elementType": "geometry",
        "stylers": {
            "color": "#204b7eff"
        }
    }
];
function toMoney(num){
    if(num){
        num = num.toFixed(0);
        num = parseFloat(num);
        num = num.toLocaleString();
        num=num.split("");
    }else{
        num=[];
    }
    return num;//返回的是字符串23,245
}
function numSplit(id,num){
    var numArr=toMoney(num),
        l=numArr.length,htmls='',d;

    for(var i=0;i<l;i++){
        var className='';
        d=numArr[i];
        if(numArr[i]==','){
            className=' class="symbol" ';
            d='&#44;'
        }
        htmls+='<span text="'+numArr[i]+'" '+className+'>'+d+'</span>';
    }
    $('#'+id).html(htmls);
    return htmls;
}
var fontColor={bottom:'#e1e8fe', left:'#ffffff', top:'#789cb6'};
var lineColor={line:'#425d81'};
var opacityColor={
  '#3fa4ff': ['rgba(62,163,255,.5)','rgba(62,163,255,.2)','rgba(62,163,255,0)'],//蓝色
  '#ffdc68': ['rgba(255,220,104,.5)', 'rgba(255,220,104,.2)','rgba(255,220,104,0)'],//黄色
  '#f66774': ['rgba(246,103,117,.5)', 'rgba(246,103,117,.2)','rgba(246,103,117,0)' ],//红色
  '#ff9650': ['rgba(255,150,80,.5)', 'rgba(255,150,80,.2)','rgba(255,150,80,0)' ],//橙色
  '#b39af1': ['rgba(180,255,241,.5)', 'rgba(180,255,241,.2)','rgba(180,255,241,0)' ]//紫色
};
opacityColorTrs=function(cArr){
    var l=cArr.length,opacityColorArr=[],tep=[],rbgString="";
    function replaceOpacity(str,opacity){
        var s=str.replace(")", ","+opacity+")");
        s= s.replace("rgb", "rgba");
        return s;
    }
    for(var i=0;i<l;i++){
        rbgString=cArr[i].colorRgb();
        tep.push(replaceOpacity(rbgString,'.8'));
        tep.push(replaceOpacity(rbgString,'.5'));
        tep.push(replaceOpacity(rbgString,'0'));
        opacityColorArr[cArr[i]]=tep;
        tep=[];
    }
    return opacityColorArr;
};
opacityColor=opacityColorTrs(['#3fa4ff','#ffdc68','#f66774','#ff9650','#b39af1','#eda477','#3ecfff']);

var linerColor={
    '#61dbb0':['#c7b2fa','#b39af1','#b39af1'],//紫色
    '#d24a4c':['#d24a4c','#fa7380','#f66775'],//红色
    '#ff9650':['#ffb650','#ffa650','#ff9750'],//橙色
    '#e7cb5c':['#ddc63b','#f6d365','#fedd96'],//黄色
    '#4ad48c':['#4ad48c','#52dba3','#5be3bd'],//绿色
    '#31a7fc':['#31a7fc','#38bcfe','#3dceff'],//蓝色
   /* '#ace06a':['#3eceff','#3fa4ff','#3fa4ff'],//草绿色
    '#f892d3':['#3eceff','#3fa4ff','#3fa4ff']*///玫红色
    '#56cfd4':['#63e7da','#56cfd4','#4cbcd0'],//水蓝色
    '#da6c3b':['#da6c3b','#e18644','#f89463']//橘色
};

//紫色，红色，橙色，黄色，绿色，蓝色，草绿色，玫红色line2Data.color=['#ff9650','#b39af1','#3fa4ff','#f66774','#ffdc68'];
defautFont=function(){
  if($(window).width()>=1921){
      return 16;
  }else{
      if($(window).width()<767){
          return 12;
      }else{
          return 14
      }

  }
};
var defaultOption={
    color:['#f66774','#3fa4ff','#b39af1','#ff9650','#ffdc68','#61dbb0','#ace06a','#f892d3'],
    fontColor:{
        bottom:'#bed0f6',
        left:'#ffffff',
        top:'#789cb6'
    },
    grid: [{
        left: '3%',
        right: 34,
        bottom: '2%',
        top:20,
        containLabel: true
    }],
    barLegend: {
        orient: 'horizontal',
        right: '3%',
        top:'0',
        borderRadius:0,
        itemHeight:7,
        itemWidth:17,
        itemGap:15,
        textStyle:{
            fontSize:defautFont(),
            width:60
        },
        selectedMode:false
    },
    symbol: 'circle',
    symbolSize: 7,
    defaultFont:defautFont(),
    yAxis: [{
        axisLabel:{
            fontSize:defautFont(),
            formatter:function(value, index){
                var x=value/10000;
                function isInteger(obj) {
                    return typeof obj === 'number' && obj%1 === 0
                }

                if(x>=0&&isInteger(x)){
                    return x+'万'
                }else{
                    return value;
                }
            }
        },
        axisTick:{
            show:false
        },
        splitNumber:3,
        nameTextStyle:{
            color:fontColor.top
        }
    }],
    xAxis: {
        type: 'category',
        axisLabel: {
            formatter: function (value, index) {

                if(value.length>=7){
                    var l=value.length;
                    var mL=Math.ceil(l/2);
                    value=value.slice(0, mL) + '\n' + value.slice(mL);
                }
                return value;
            },
            fontSize:defautFont()

        },
        axisTick: {
            show: false
        },
        splitLine:{
            lineStyle:{
                color:lineColor.line
            }
        },
        nameGap:5
    },
    tooltip : {
        trigger: 'axis',
        axisPointer : {            // 坐标轴指示器，坐标轴触发有效
            type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
        },
        backgroundColor:'rgba(18,109,222,.8);',
        padding:[10,15],
        extraCssText:'box-shadow: 0 0 8px 0 rgba(255,255,255,0.3) inset;border-radius:0;line-height: 26px;',
        position:function(point,params,dom,rect,size){
            var position=point,conSize=[],domSize=[];
            position[0]=position[0]+6;
            position[1]=position[1]+6;
            conSize.push(size.viewSize[0]);
            conSize.push(size.viewSize[1]);
            domSize.push($(dom).outerWidth());
            domSize.push($(dom).outerHeight());

            if(position[0]+domSize[0]>conSize[0]){
                position[0]=conSize[0]-domSize[0];
            }
            if(position[1]+domSize[1]>conSize[1]){
                position[1]=conSize[1]-domSize[1];
            }

            return position;
        },
    }
};
var defaultPieIndexOption={
    color:['#32a9fc','#daa73b','#e85557'],
    tooltip : {
       show:false
    },
    grid:defaultOption.grid,
    series : [{
        name: '',
        type: 'pie',
        radius : ['0%', '53%'],
        center: ['50%', '50%'],
        minAngle:5 ,
        data:[],
        stillShowZeroSum:false,
        itemStyle: {
            //color:['#32a9fc','#daa73b','#e85557'],
            emphasis: {
                shadowBlur: 10,
                shadowOffsetX: 5,
                shadowColor: 'rgba(0, 0, 0, .1)'
            }
        },
        label:{
            normal:{
                formatter: "{b}\n {d}%",
                fontSize:12,
                lineHeight:30,
                show:true,
                position: 'inner',
                color:'#e6f6ff'
            },
            emphasis: {
                //fontWeight:'bold',
                //show:true

            }
        },
        selectedMode:false,
        selectedOffset:16
    },{
        type: 'pie',
        radius : ['68%', '72%'],
        center: ['50%', '50%'],
        minAngle:5 ,
        data:[],
        label:{
            formatter: "{b} {d}%",
            position: 'outside',
            color:'rgba(230,246,255,.8)',
            fontSize:defautFont()
        },
        labelLine:{
            lineStyle:{
                type:'dotted',
                color:'#e6f6ff'
            }
        },
        emphasis:{
            label:{
                fontWeight:'bold'
            }
        }
    }]
};
var defaultPieOption={
    //color:defaultOption.color,
    tooltip : {
        formatter: "{b}<br />{c}件<br />{d}%",
        position: function (point, params, dom, rect, size) {
            return [(size.viewSize[0]-size.contentSize[0])/2, (size.viewSize[1]-size.contentSize[1])/2];
        },
        backgroundColor:'rgba(50,50,50,0)',
        extraCssText:'display:block!important;text-align:center;animation:flipInY 4s infinite linear; -moz-animation:flipInY 4s infinite linear;  -webkit-animation:flipInY 4s infinite linear; -o-animation:flipInY 4s infinite linear; ',
        show:true,
        transitionDuration:0,
        textStyle:{
            fontSize:defautFont()
        }
    },
    grid:defaultOption.grid,
    series : {
        name: '',
        type: 'pie',
        radius : ['55%', '83%'],
        center: ['50%', '50%'],
        minAngle:10 ,
        data:[],
        stillShowZeroSum:false,
        itemStyle: {
            emphasis: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
            }
        },
        label:{
            normal:{
                formatter: "{b}\n {d}%",
                fontSize:defaultOption.defaultFont,
                lineHeight:30,
                show:false,
                position: 'center'
            },
            emphasis: {
                //fontWeight:'bold',
                //show:true

            }
        },
        selectedMode:false,
        selectedOffset:16
    }
};
var flagImage={
    0:'./images/up.png',
    1:'./images/down.png',
    2:'./images/same.png'
};
var barImage={
    0:'./images/chart_bg.png'
};
function  getgridW() {
    if($(window).width()<=375){
        return '25%';
    }else{
        return '32%';
    }
}
var defaultBarOption={
    color:['#4ad48c','#31a7fc','#61dbb0','#3fa4ff'],
    grid: [
        {
        //左图
        gridIndex: 0,
        top: 50,
        width: getgridW(),
        left: 55
    }, {
        //右图
        gridIndex: 1,
        top: 50,
        right:55,
        width: getgridW()

    }, {
        //中间标题
        gridIndex: 2,
        top: 50,
        show: false,
        left: '48%',
        width: '0%'
        }
    ],
    legend:{
        data:[1,2]
    },
    yAxis:[
        {
            type: 'category',
            inverse:true,
            axisTick:{show:false},
            axisLabel : {show:false},
            axisLine: {
                show: false
            },
            gridIndex: 0,

        },{
            type: 'category',
            inverse:true,
            axisTick:{show:false},
            axisLabel : {
                show:false
            },
            axisLine: {
                show: false
            },
            gridIndex: 1
            //offset:55
        },{
            type: 'category',
            inverse:true,
            axisTick:{show:false},
            position: 'right',
            axisLabel : {
                show:true,
                align: 'center',
                fontSize:14
            },
            axisLine: {
                show: false
            },
            gridIndex: 2
        },{
            gridIndex: 0,
            inverse: true,
            position: 'left',
            offset:65,
            axisLine: {
                show: false
            },
            axisTick: {
                show: false
            },
            axisLabel: {
                show: true,
                textStyle: {
                    color: '#e6f6ff',
                    fontSize: 12
                },
                rich:{
                    value:{
                        color:'#90a6c7',
                        padding:[0,6,0,6]
                    },
                    0:{
                        height: 11,
                        align: 'center',
                        backgroundColor: {
                            image: flagImage['0']
                        }
                    },
                    1:{
                        height: 11,
                        align: 'center',
                        backgroundColor: {
                            image: flagImage['1']
                        }
                    },
                    2:{
                        height: 11,
                        align: 'center',
                        backgroundColor: {
                            image: flagImage['2']
                        }
                    }
                },
                inside:true
            }
        }
        ,{
            gridIndex: 1,
            inverse: true,
            position: 'right',
            //offset:-7,
            axisLine: {
                show: false
            },
            axisTick: {
                show: false
            },
            axisLabel: {
                show: true,
                textStyle: {
                    color: '#e6f6ff',
                    fontSize: 12
                },
                rich:{
                    value:{
                        color:'#90a6c7',
                        padding:[0,6,0,6]
                    },
                    0:{
                        height: 11,
                        align: 'center',
                        backgroundColor: {
                            image: flagImage['0']
                        }
                    },
                    1:{
                        height: 11,
                        align: 'center',
                        backgroundColor: {
                            image: flagImage['1']
                        }
                    },
                    2:{
                        height: 11,
                        align: 'center',
                        backgroundColor: {
                            image: flagImage['2']
                        }
                    }
                },
                inside:false
            }
        }
    ],
    xAxis:[
        {
            type: 'value',
            inverse: true,
            axisTick:{show: false, inside:false},
            axisLabel : {show: false},
            axisLine: {// Y轴轴线样式
                show: false
            },
            splitLine: {
                show: false
            },
            gridIndex: 0/*,
            boundaryGap:['5%','5%']*/
        },{
            type: 'value',
            axisTick:{show: false},
            axisLabel : {show: false},
            axisLine: {// Y轴轴线样式
                show: false
            },
            splitLine: {
                show: false
            },
            gridIndex: 1/*,
            boundaryGap:['20%','20%']*/
        }, {
            gridIndex: 2,
            show: false
        }
    ],
    tooltip:defaultOption.tooltip
};
var defaultBar2Option={
    color:['#d24a4c','#da6c3b','#e7cb5c','#31a7fc','#31a7fc'],
    grid:[
        {
            gridIndex: 0,
            top: 10,
            left:145,
            right:110
        },
        {
            gridIndex: 1,
            top: 10,
            left:145,
            right:110
        }
    ],
    xAxis:[
        {
        type: 'value',
        inverse: false,
        axisTick:{show: false, inside:false},
        axisLabel : {show: false},
        axisLine: {// Y轴轴线样式
            show: false
        },
        splitLine: {
            show: false
        },
        gridIndex: 0
    },{
        type: 'value',
        inverse: true,
        axisTick:{show: false, inside:false},
        axisLabel : {show: false},
        axisLine: {// Y轴轴线样式
            show: false
        },
        splitLine: {
            show: false
        },
        gridIndex: 1
    }
    ],
    yAxis:[
        {
            type: 'category',
            inverse:true,
            axisTick:{show:false},
            axisLabel : {
                align:'left',
                inside:true,
                margin:-145,
                rich:{
                    value:{
                        color:'#fff',
                        fontSize:15,
                        //padding:[0,3,0,3],
                        width:110
                    },
                    upValue:{
                        color:'#e6676f',
                        fontSize:14,
                        padding:[0,3,0,3]
                    },
                    downValue:{
                        color:'#71f283',
                        fontSize:14,
                        padding:[0,3,0,3]
                    },
                    sameValue:{
                        color:'#3ecefe',
                        fontSize:14,
                        padding:[0,3,0,3]
                    },
                    0:{
                        height: 11,
                        align: 'center',
                        backgroundColor: {
                            image: flagImage['0']
                        }
                    },
                    1:{
                        height: 11,
                        align: 'center',
                        backgroundColor: {
                            image: flagImage['1']
                        }
                    },
                    2:{
                        height: 11,
                        align: 'center',
                        backgroundColor: {
                            image: flagImage['2']
                        }
                    }
                }
            },
            axisLine: {
                show: false
            },
            gridIndex: 0
        },{
            type: 'category',
            inverse:true,
            axisTick:{show:false},
            axisLabel : {
                align:'left',
                inside:true,
                margin:-135
            },
            axisLine: {
                show: false
            },
            gridIndex: 0
        },
        {
            type: 'category',
            inverse:true,
            axisTick:{show:false},
            axisLabel : {show:false},
            axisLine: {
                show: false
            },
            gridIndex: 1
        }
    ]
    //tooltip:defaultOption.tooltip

};
var defaultBar3Option={
    color:['#31a7fc','#4ad48c','#e7cb5c','#da6c3b','#d24a4c'],
    grid:[{
        top:35,
        left:'3%',
        right:'2%',
        bottom:'35',
        containLabel: true
    }],
    legend:defaultOption.barLegend,
    yAxis:defaultOption.yAxis,
    xAxis:defaultOption.xAxis,
    tooltip:defaultOption.tooltip
};
var defaultBarLineOption={
    color:['#3fa4ff','#f66775','#ffdc68'],
    grid: defaultOption.grid,
    legend:defaultOption.barLegend,
    yAxis:[
        {
        type: 'category',
        inverse: true,
        axisTick:{show:false},
        axisLabel : {show:false},
        axisLine: {
            show: false
        },
        data: ['1','2']
    },{
        type: 'category',
        inverse: true,
        axisTick:{show:false},
        axisLabel : {show:false},
        axisLine: {
            show: false
        },
        data: ['1','2']
    }
    ],
    xAxis:[
        {
        type: 'value',
        axisTick:{show: false, inside:false},
        axisLabel : {show: false},
        axisLine: {// Y轴轴线样式
            show: false
        },
        splitLine: {
            show: false
        }
    },{
        type: 'value',
        axisTick:{show: false, inside:false},
        axisLabel : {show: false},
        axisLine: {// Y轴轴线样式
            show: false
        },
        splitLine: {
            show: false
        }
    }
    ],
    tooltip:defaultOption.tooltip
};
var defaultLineOption={
    color: ['#eda477', '#3ecfff', '#ffdc68','#ff9650','#b39af1'],
    legend:defaultOption.barLegend,
    yAxis:defaultOption.yAxis,
    xAxis:defaultOption.xAxis,
    tooltip:{
        trigger: 'axis',
        axisPointer:{
            type:'line'
        },
        formatter:function(params, ticket, callback){
            //console.log(params);
            var xAxisName=params[0].axisId,html='<span style="font-size: 16px;">'+params[0].axisValue+'</span>',l=params.length;
            if(xAxisName.indexOf('series')==-1){
                html+=xAxisName.substring(0,xAxisName.length-1);
            }
            for(var i=0;i<l;i++){
                html+='<br /><span class="tooltipCir" style="background-color:'+params[i].color+'"></span>'+params[i].seriesName+'：'+params[i].value;
            }
            return html;
        },
        backgroundColor:'rgba(18,109,222,.8);',
        padding:[10,15],
        extraCssText:'box-shadow: 0 0 8px 0 rgba(255,255,255,0.3) inset;border-radius:0;',
        position:function(point,params,dom,rect,size){
            var position=point,conSize=[],domSize=[];
            position[0]=position[0]+6;
            position[1]=position[1]+6;
            conSize.push(size.viewSize[0]);
            conSize.push(size.viewSize[1]);
            domSize.push($(dom).outerWidth());
            domSize.push($(dom).outerHeight());

            if(position[0]+domSize[0]>conSize[0]){
                position[0]=conSize[0]-domSize[0];
            }
            if(position[1]+domSize[1]>conSize[1]){
                position[1]=conSize[1]-domSize[1];
            }

            return position;
        },

    }
};
var defaultMapOption={
    tooltip:{
        trigger:'item',
        showDelay:100,
        padding:0,
        confine:true,
        position:function(point,params,dom,rect,size){
            var position=point,conSize=[],domSize=[];
            position[0]=position[0]+6;
            position[1]=position[1]+6;
            conSize.push(size.viewSize[0]/1.05);
            conSize.push(size.viewSize[1]/1.05);
            domSize.push($(dom).find('.map-tip').outerWidth());
            domSize.push($(dom).find('.map-tip').outerHeight());

            if(position[0]+domSize[0]>conSize[0]){
                position[0]=conSize[0]-domSize[0];
            }
            if(position[1]+domSize[1]>conSize[1]){
                position[1]=conSize[1]-domSize[1];
            }


            return position;
        },
        formatter:function (params, ticket, callback) {
            var value=0,htmlnum,tipHtml;
            if(params.seriesIndex==1){
                value=params.data.value;
                htmlnum=numSplit('num2',value);
                tipHtml ='<div class="map-tip">'+
                '                                    <i class="arrow"></i>'+
                '                                    <div class="city-name">'+params.data.name+'</div><div class="sort">本月第<span>'+(params.dataIndex+1)+'</span>名</div>'+
                '                                    <div class="num-split clearfix" id="num2">'+htmlnum+
                '                                    </div>'+
                '                                </div>';
            }else if(params.seriesIndex==0){
                htmlnum=numSplit('num2',params.data.value[2]);
                tipHtml ='<div class="map-tip">'+
                '                                    <i class="arrow"></i>'+
                '                                    <div class="city-name">'+params.data.name+'</div><div class="sort">本月第<span>'+(params.dataIndex+1)+'</span>名</div>'+
                '                                    <div class="num-split clearfix" id="num2">'+htmlnum+
                '                                    </div>'+
                '                                </div>';
            }

            return tipHtml;
        }
    },
    geo: [
        {
        map:'FZ',
        roam: false,
        zlevel:1,
        z:1,
        aspectScale:0.92,
        label: {
            normal: {
                show: false
            },
            emphasis: {
                show: false
            }
        },
        itemStyle: {
            normal: {
                borderColor:'#9bc0f4',
                borderWidth:1.5,
                areaColor: '#154eb1'
            },
            emphasis: {
                borderWidth:1.5,
                areaColor: '#1f6ccf',
                borderColor:'#9bc0f4'
            }
        }
    },
        {
            map:'FZ',
            roam: false,
            zlevel:0,
            aspectScale:0.94,
            center:[118.1039,25.990],
            label: {
                normal: {
                    show: false
                },
                emphasis: {
                    show: false
                }
            },
            itemStyle: {
                normal: {
                    borderColor:'rgb(30,49,108)',
                    borderWidth:1.5,
                    areaColor: 'rgb(30,49,108)'

                },
                emphasis: {
                    borderWidth:1.5,
                    areaColor: 'rgb(30,49,108)',
                    borderColor:'rgb(30,49,108)'
                }
            }
        }
        ,
        {
            map:'FZ',
            roam: false,
            zlevel:0,
            aspectScale:0.94,
            center:[118.11,26.050],
            label: {
                normal: {
                    show: false
                },
                emphasis: {
                    show: false
                }
            },
            itemStyle: {
                normal: {
                    borderColor:'rgb(30,49,108)',
                    borderWidth:1.5,
                    areaColor: 'rgb(30,49,108)'

                },
                emphasis: {
                    borderWidth:1.5,
                    areaColor: 'rgb(30,49,108)',
                    borderColor:'rgb(30,49,108)'
                }
            }
        }
        ,
        {
            map:'FZ',
            roam: false,
            zlevel:0,
            aspectScale:0.94,
            center:[118.1239,26.050],
            label: {
                normal: {
                    show: false
                },
                emphasis: {
                    show: false
                }
            },
            itemStyle: {
                normal: {
                    borderColor:'rgb(30,49,108)',
                    borderWidth:1.5,
                    areaColor: 'rgb(30,49,108)'

                },
                emphasis: {
                    borderWidth:1.5,
                    areaColor: 'rgb(30,49,108)',
                    borderColor:'rgb(30,49,108)'
                }
            }
        }
    ],
    series:[
        {
            name:'散点图',
            type:'effectScatter',
            effectType:'ripple',
            rippleEffect:{
                brushType:'stroke',
                period:3
            },
            coordinateSystem:'geo',
            symbolSize: function (val){
                return val[2] / 200;
            },
            symbol:'circle',
            geoIndex:0,
            label: {
                normal: {
                    formatter:function(params ){
                        return params.name;
                    } ,
                    position: 'top',
                    show: true,
                    color:'#fff',
                    lineHeight:20,
                    fontSize:defautFont()
                },
                emphasis: {
                    show: true,
                    color:'#fff'
                }
            },

            itemStyle:{
                borderColor:'#f1c74b',
                color:'#f1c74b'
            },
            emphasis:{
                itemStyle:{
                    borderColor:'#f68454',
                    color:'#f68454'
                }

            },
            zlevel:5
        },
        {
            name:'地图图形',
            mapType:'FZ',
            type:'map',
            geoIndex:0,
            data:[],
            itemStyle:{
                areaColor:'#fff',
                borderWidth:1.5
            },
            zlevel:2
        },
        {
            name:'地图连线',
            type:'lines',
            geoIndex:0,
            lineStyle: {
                color: '#fff7e5',
                width: 0.5,
                curveness: 0.3
            },
            zlevel:3
        },
        {
            name:'地图阴影',
            mapType:'FZ',
            type:'map',
            geoIndex:1,
            aspectScale:1,
            data:[],
            itemStyle:{
                areaColor:'rgb(30,49,108)',
                borderWidth:7
            },
            zlevel:4
        },
        {
            name:'地图阴影',
            mapType:'FZ',
            type:'map',
            geoIndex:2,
            aspectScale:1,
            data:[],
            itemStyle:{
                areaColor:'rgb(30,49,108)',
                borderWidth:7
            },
            zlevel:5
        },
        {
            name:'地图阴影',
            mapType:'FZ',
            type:'map',
            geoIndex:3,
            aspectScale:1,
            data:[],
            itemStyle:{
                areaColor:'rgb(30,49,108)',
                borderWidth:7
            },
            zlevel:6
        }


    ]

};

var chartFun=function(){};
chartFun.prototype={
    extendOption:function(defaultOpt,settingOpt){
        var opt={};
        opt=jQuery.extend(true, opt, defaultOpt, settingOpt);
        return opt;
    },
    getLegend:function(series){
        var l=series.length,legend=[];
        for(var i=0;i<l;i++){
            if(series[i].type!='custom'){
                legend.push(series[i].name);
            }

        }
        return legend;
    },
    getLegend2:function(series){
        var l=series.data.length,legend=[];
        var data=this.deepClone(series.data);
        for(var i=0;i<l;i++){
            legend.push(data[i].name);

        }
        return legend;
    },
    setPieHeight:function(id){

        var conW=$('#'+id).width(),conH=$('#'+id).parent().height();
        if($(window).width()>767){
            conH=(conW/2-20<conH)?conW/2-20:conH;
            $('#'+id).css({height:conH,top:'50%',marginTop:-conH/2});
        }else{
            var minh=150;
            conH=conW/2-20>minh?conW/2-20:minh;
            $('#'+id).css({height:conH,top:'0',marginTop:0,minHeight:conH});
        }


        return {conW:conW,conH:conH};
    },
    getPieIndexOption:function(data){
        var me=this;
        var optcolor=[
            {color:'#32a9fc',childColor:['#7fa2f0','#37b7fe','#68dddc','#5bdc67']},
            {color:'#daa73b',childColor:['#b1da6a','#e7cb5c','#daa73b','#da6c3b']},
            {color:'#e85557',childColor:['#e85557']}
        ];
        var placeHolderStyle = {
            normal: {
                color: 'rgba(0, 0, 0, 0)',
                borderColor: 'rgba(0, 0, 0, 0)',
                borderWidth: 0
            }
        },opt,totalNum=0;

        //=========数据处理
        var s1Data=this.deepClone(data.series[0].data),s2Data=[],l=s1Data.length;

        //外部数据获取
        var index=0;
        for(var i=0;i<l;i++){
            var tempdata=me.deepClone(s1Data[i]),l1=tempdata.child.length,
                childIndex=[];
            for(var j=0;j<l1;j++){
                tempdata.child[j].itemStyle={
                    color:optcolor[i].childColor[j],
                    borderColor:optcolor[i].childColor[j],
                    borderWidth:5
                };
                s2Data.push(me.deepClone(tempdata.child[j]));
                childIndex.push(index);
                index++;
            }
            s1Data[i].childIndex=childIndex;
            totalNum+=tempdata.value;
        }

        //var spilt=0;
        var spilt=me.getPieSpilt(s2Data,0.015);
        var sa=(spilt/2)/totalNum*360;
        l=s2Data.length;
        var newS2Data=[];
        //外部圆环添加间距
        for(i=0;i<l;i++){
            var value=s2Data[i].value;
            s2Data[i].value1= value;
            s2Data[i].percent1=((value/totalNum)*100).toFixed(1);
            if(value>spilt){
                s2Data[i].value=value-spilt;
            }

        }
        for(i=0;i<l;i++){
            if(s2Data[i].percent1<=5){
                if(s2Data[i-1].percent1>5){
                    s2Data[i]. labelLine={
                        length:5,
                        length2:45
                    }
                }else{

                    s2Data[i]. labelLine={
                        length:15,
                        length2:20
                    }

                }
            }else{
                if(s2Data[i+1]){
                    if(s2Data[i+1].percent1<=5){
                        s2Data[i].labelLine={
                            length:5,
                            length2:35
                        }
                    }
                }
            }
            newS2Data.push(s2Data[i], {
                //间隔
                value: spilt,
                name: '无',
                itemStyle: placeHolderStyle,
                label: {
                    show: false
                },
                labelLine: {
                    show: false
                },
                emphasis:{
                    labelLine:{
                        show: false
                    }
                }
            });
        }

        //内部圆环
        var seris1={
            name: 'innerPie',
            type: 'pie',
            radius : ['0%', '56%'],
            center: ['50%', '50%'],
            minAngle:5 ,
            avoidLabelOverlap:true,
            hoverOffset:7.5,
            label:{
                normal:{
                    formatter: function(val){
                        return val.name+'\n '+val.percent.toFixed(0)+'%';
                    },
                    fontSize:12,
                    lineHeight:30,
                    show:true,
                    position: 'inside',
                    color:'#e6f6ff'
                },
                emphasis:{
                    formatter: function(val){
                        return val.name+'\n '+me.formatNum(val.data.value)+'件'+val.percent.toFixed(0)+'%';
                    }
                }
            },
            data:s1Data
        };

        //外部圆环
        var seris2={
            name:'outerPie',
            type:'pie',
            radius : ['70%', '74%'],
            center: ['50%', '50%'],
            minAngle:1 ,
            avoidLabelOverlap:false,
            hoverOffset:5,
            label:{
                normal:{
                    formatter: function(val){
                        return val.name+' '+val.data.percent1+'%';
                    },
                    color:'rgba(230,246,255,.8)',
                    fontSize:defautFont(),
                    show:true,
                    lineHeight:40
                },
                emphasis:{
                    show:true,
                    formatter: function(val){
                        return val.name+' '+val.data.percent1+'%  '+me.formatNum(val.data.value1)+'件';
                    }
                }

            },
            labelLine:{
                lineStyle:{
                    type:'dotted',
                    color:'#e6f6ff'
                },
                length:10,
                length2:25
            },
            data:newS2Data,
            startAngle:90-sa,

        };
        opt={
            color:['#32a9fc','#daa73b','#e85557'],
            tooltip : {
                show:false
            },
            grid:[{
                left: '5%',
                right: 34,
                bottom: 10,
                top:10,
                containLabel: true
            }],
            series:[seris1,seris2]
        };
        return opt;
    },
    getPie2Option:function(data){
        var series=[],temppieData=[], l,pieData,me=this;
        var color2=['#37b7fe','#e85557','#da6c3b','#e7cb5c','#b1da6a','#e7cb5c','#da6c3b','#e85557'];
        var placeHolderStyle = {
            normal: {
                color: 'rgba(0, 0, 0, 0)',
                borderColor: 'rgba(0, 0, 0, 0)',
                borderWidth: 0
            }
        };
        var tempS={
            data:[{name:data.series[0].name,value:2}],
            radius : ['50%', '51%'],
            center: ['50%', '50%'],
            silent:true,
            label:{
                normal:{
                    position:'center',
                    formatter:'{b}',
                    fontSize:18
                }
            }
        };
        series.push(tempS);//内部圆环

        //外部圆环
        pieData=this.deepClone(data.series[0].data);
        l=pieData.length;

        //求取间隔
        var spilt=this.getPieSpilt(pieData,0.03);

        for(var i=0;i<l;i++){
            //图形
            temppieData.push({
                name:pieData[i].name,
                value:pieData[i].value,
                itemStyle:{
                    borderWidth: 7,
                    color:color2[i],
                    borderColor:color2[i]

                }
            }, {
                //间隔
                value: spilt,
                name: '',
                itemStyle: placeHolderStyle,
                label: {
                    show: false
                },
                labelLine: {
                    show: false
                },
                emphasis:{
                    labelLine:{
                        show: false
                    }
                }
            });
        }
        var getLine1=function () {
            if($(window).width()>=1921){
                return 12;
            }else{
                if($(window).width()<480){
                    return 5;
                }else{
                    return 9;
                }

            }
        }
        var getLine2=function () {
            if($(window).width()>=1921){
                return 25;
            }else{
                if($(window).width()<480){
                    return 15;
                }else{
                    return 25
                }

            }
        }
        series.push({
            data:temppieData,
            radius : ['66%', '70%'],
            /*label:{
                normal:{
                   // formatter:'{b}',
                }

            }*/
            startAngle:70,
            label:{
                formatter: function(val){
                    return ['{a|'+ val.name+'}\n',
                        '{a|'+me.formatNum(val.value)+'}  ',
                        '{a|'+val.percent+'%}'
                        ].join('');
                },
                rich:{
                    a:{
                        fontSize:defautFont(),
                        lineHeight:18,
                        color:'rgba(230,246,255,.8)'
                    }
                },
                align:'center'
            },
            avoidLabelOverlap:false,
            labelLine: {
                length:getLine1(),
                length2:getLine2(),
            }
        });
        var pieOption={
            series:series
        };
        var newo=this.extendOption(defaultPieIndexOption,pieOption);
        if(data.color){
            newo.color=data.color
        }
        return newo;
    },
    getPie3Option:function(data){
        var me=this,
            optcolor=[
            {color:'#2ba5fe',childColor:['#7fa2f0','#79c8ff','#79deff','#7eeef5']},
            {color:'#40ce87',childColor:['#72eccb','#70e1a0','#7edd68','#addd68']},
            {color:'#e8c93f',childColor:['#d5e641','#e6e441','#e6d141','#fbce55']},
            {color:'#e57a42',childColor:['#ffbe57','#ffa23f','#ff873f','#fa6531']},
            {color:'#e74765',childColor:['#fa5231','#f44444','#f63b5e','#ef4585']}
        ],
            placeHolderStyle = {
            normal: {
                color: 'rgba(0, 0, 0, 0)',
                borderColor: 'rgba(0, 0, 0, 0)',
                borderWidth: 0
            }
            }, opt,totalNum=0;

        //=========数据处理
        var s1Data=this.deepClone(data.series[0].data),s2Data=[],l=s1Data.length;
        //外部数据获取
        var index=0;
        for(var i=0;i<l;i++){
            var tempdata=s1Data[i],l1=tempdata.child.length,
                childIndex=[];
            for(var j=0;j<l1;j++){
                tempdata.child[j].itemStyle={
                    color:optcolor[i].childColor[j],
                    borderColor:optcolor[i].childColor[j],
                    borderWidth:5
                };
                //饼图的子index
                s2Data.push(me.deepClone(tempdata.child[j]));

                childIndex.push(index);
                index++;
            }
            s1Data[i].childIndex=childIndex;

            totalNum+=tempdata.value;
        }
        var spilt=me.getPieSpilt(s2Data,0.008).toFixed(0);
        var tempSData=[];
        //百分比处理
        for(i=0;i<l;i++){
            var tempdata=s1Data[i],l1=tempdata.child.length;
            tempSData.push({child:[]});
            for(j=0;j<l1;j++){
                var value=tempdata.child[j].value;
                tempdata.child[j].percent1=((value/totalNum)*100).toFixed(1);
                tempSData[i].child.push({value:value-spilt});
            }
        }
        for(i=0;i<l;i++){
            var thisD=tempSData[i].child,l=thisD.length;
            for(j=0;j<l;j++){
                if(thisD[j].value<0){
                    thisD[j].value=0;

                }
            }
        }

        //var spilt=0;
        var sa=(spilt/2/totalNum)*360
        l=s2Data.length;
        var newS2Data=[];
        //外部圆环添加间距
        for(i=0;i<l;i++){
            var value=s2Data[i].value;
            s2Data[i].value1= value;
            s2Data[i].percent1=((value/totalNum)*100).toFixed(1);
            if(value>spilt){
                s2Data[i].value=value-spilt;
            }else{
                s2Data[i-1].value=s2Data[i-1].value+(value-spilt)<0?0:s2Data[i-1].value+(value-spilt);
                s2Data[i].value=0;
            }
            //外部图形
            newS2Data.push(s2Data[i], {
                //间隔
                value: spilt,
                name: '无',
                itemStyle: placeHolderStyle,
                label: {
                    show: false
                },
                labelLine: {
                    show: false
                },
                emphasis:{
                    labelLine:{
                        show: false
                    }
                }
            });
        }

        //内部圆环
        var seris1={
            name: 'innerPie',
            type: 'pie',
            radius : ['0%', '58%'],
            center: ['50%', '50%'],
            minAngle:5 ,
            avoidLabelOverlap:false,
            selectedMode:'single',
            label:{
                normal:{
                    formatter: function(val){
                        return val.name+'\n '+val.percent.toFixed(0)+'%';
                    },
                    fontSize:14,
                    lineHeight:30,
                    show:true,
                    position: 'inside',
                    color:'#e6f6ff'
                },
                emphasis:{
                    formatter: function(val){
                        return val.name+'\n '+me.formatNum(val.data.value)+'件'+val.percent.toFixed(0)+'%';
                    }
                }
            },
            data:s1Data,

            tooltip:{
                show:true,
                formatter:function(param){
                    var a=param,html='',child=param.data.child,l=child.length;
                    for(var i=0;i<l;i++){
                        var tempC=child[i];
                        html+='<div><span class="tooltipCir" style="background-color: '+tempC.itemStyle.color+'"></span><span class="dataName">'+tempC.name+'</span>：'+me.formatNum(tempC.value)+'件，占'+tempC.percent1+'%</div>';
                    }
                    return '<div style="font-size: 16px;padding-bottom: 5px">'+param.name+'&nbsp;&nbsp;'+me.formatNum(param.value)+'件</div>'+html;
                },
                backgroundColor:'rgba(18,109,222,.8);',
                padding:[10,15],
                extraCssText:'box-shadow: 0 0 8px 0 rgba(255,255,255,0.3) inset;border-radius:0;line-height: 26px;',
                position:function(point,params,dom,rect,size){
                    var position=point,conSize=[],domSize=[];
                    position[0]=position[0]+6;
                    position[1]=position[1]+6;
                    conSize.push(size.viewSize[0]);
                    conSize.push(size.viewSize[1]);
                    domSize.push($(dom).outerWidth());
                    domSize.push($(dom).outerHeight());

                    if(position[0]+domSize[0]>conSize[0]){
                        position[0]=conSize[0]-domSize[0];
                    }
                    if(position[1]+domSize[1]>conSize[1]){
                        position[1]=conSize[1]-domSize[1];
                    }

                    return position;
                }
            },
            animationType:'scale'
        };

        //外部圆环
        var seris2={
            name:'outerPie',
            type:'pie',
            radius : ['73%', '78%'],
            center: ['50%', '50%'],
            minAngle:0,
            avoidLabelOverlap:false,
            hoverOffset:0,
            selectedMode :'multiple',

            label:{
                normal:{
                    formatter: function(val){
                        return val.name+'\n'+me.formatNum(val.data.value1)+'件 '+val.data.percent1+'%';
                    },
                    color:'rgba(230,246,255,.8)',
                    fontSize:14,
                    show:false,
                    lineHeight:40
                },
                emphasis:{
                    show:true
                }

            },
            labelLine:{
                lineStyle:{
                    type:'dotted',
                    color:'#e6f6ff'
                },
                length:10,
                length2:27
            },
            data:newS2Data,
            silent:true,
            cursor:'pointer',
            startAngle:90-sa
        };
        opt={
            color:['#2ba5fe','#40ce87','#e8c93f','#e57a42','#e74765'],
            tooltip : {
                show:false
            },
            grid:[{
                left: '5%',
                right: 34,
                bottom: 10,
                top:10,
                containLabel: true
            }],
            series:[seris1,seris2]
        };
        console.log(opt);
        return opt;
    },
    formatNum:function(num){
        if(num>=1000){
            var str=num.toFixed(0);
            str=(str/10000).toFixed(1)+'万';
            return str;
        }else{
            return num;
        }
    },
    getBarOption:function(data,flag){
        //是默认按第一个数据降序排序
        if(flag){
            data=this.barSort(data,0);
        }

        var seriesData=data.series,
            l=seriesData.length,yAxisData;

        //默认使用第一个作为y轴
        yAxisData=this.getLegend2(seriesData[0]);
        //颜色设置
        if(!data.color){
            data.color=defaultBarOption.color;
        }
        //数据填充样式设置
        for(var i=0;i<l;i++){
            seriesData[i].type='bar';
            seriesData[i].barWidth=10;
            seriesData[i].gridIndex=i;
            seriesData[i].xAxisIndex=i;
            seriesData[i].yAxisIndex=i;
            seriesData[i].itemStyle={
                color: new echarts.graphic.LinearGradient(0, 0, 1, 0,
                    [
                        {offset: 0, color: linerColor[data.color[i]][0]},
                        {offset: 1, color: linerColor[data.color[i]][2]}
                    ]),
                barBorderRadius:15,
                borderWidth:0
            };
            seriesData[i].label={
                show:false
            }
        }
        var yAxis4={
            axisLabel:{
                formatter: function (value,index) {
                    var flag=seriesData[0].data[index].flag;
                    return '{value|'+value+'%}{' + flag + '| }';
                }
            },
            data:seriesData[0].data
        };
        var yAxis5={
            axisLabel:{
                formatter: function (value,index) {
                    var flag=seriesData[1].data[index].flag;
                    return '{' + flag + '| }{value|'+value+'%}';
                }
            },
            data:seriesData[1].data
        };
        var yAxis={data:yAxisData};
        //数据合成
        var settingOpt={
            xAxis:[data.xAxis,data.yAxis[0],data.yAxis[0]],
            yAxis:[yAxis,yAxis,yAxis,yAxis4,yAxis5],
            series:seriesData,
            legend:{
                show:false
            },
            tooltip:{
                formatter:'{b0}<br />{a}：{c}%',
                backgroundColor:'rgba(50,50,50,0.45)',
                axisPointer:{
                    shadowStyle:{
                        color:'rgba(150,150,150,0.15)'
                    }
                }
            }
        };

        var BarOption=this.extendOption(defaultBarOption,settingOpt);
        if(data.color){
            BarOption.color=data.color;
        }
        return BarOption;
    },
    getBar2Option:function(data){
        var seriesData=this.deepClone(data.series[0].data),seriesData1=this.deepClone(data.series[0].data),
            l=seriesData.length,bgseriesData=[],preArr=[],numArr=[],
            barWidth='40%';
        var maxValue=seriesData[0].value/0.9;
        var yAxis1={
            axisLabel:{
                formatter: function (value,index) {
                    var flagNum=seriesData[index].flagNum,numStyle,num='';
                    if(flagNum==0){
                        numStyle='upValue';
                    }else if(flagNum==1){
                        numStyle='downValue';
                    }else if(flagNum==2){
                        numStyle='sameValue';
                    }
                    if(seriesData[index].num>1){
                        num=seriesData[index].num;
                    }
                    var str='{value|'+value+'}{'+flagNum+'|}{'+numStyle+'|'+num+'}';
                    return str;
                },
                fontSize:16
            },
            data:data.yAxis[0].data
        };
        var yAxis2={
            data:data.yAxis[0].data
        };
        var xAxis1={
            max:maxValue
        };

        //颜色处理，背景处理
        for(var i=0;i<l;i++){
            var value=seriesData[i].value,color;
            color=defaultBar2Option.color[i];
            seriesData[i].itemStyle={
                color:new echarts.graphic.LinearGradient(0, 0, 1, 0,
                    [
                        {offset: 0, color: linerColor[color][0]},
                        {offset: 1, color: linerColor[color][2]}
                    ])
            };

            //灰色背景
            var thisD=this.deepClone(seriesData1[i]);
            thisD.value=maxValue;
            thisD.value1=seriesData1[i].value;
            bgseriesData.push(thisD);

            preArr.push(seriesData1[i].pre);
            numArr.push(seriesData1[i].value);
        }

        //条纹背景
        var PatternImgA = new Image();
        PatternImgA.src = barImage['0'];

        //获得百分比宽度
        preArr=preArr.sort(function(a,b){
            return b-a;
        });
        var prewidth=(preArr[0].toFixed(0).toString().length+1)*8+5;
        prewidth=prewidth>58?58:prewidth;

        numArr=numArr.sort(function(a,b){
            return b-a;
        });
        var numwidth=(numArr[0].toFixed(0).toString().length+1)*8+5;
        numwidth=numwidth>58?58:numwidth;

        var settingOpt={
            yAxis:[yAxis1,yAxis2],
            xAxis:[xAxis1,xAxis1],
            series:[
                {
                    type:'bar',
                    barWidth:barWidth,
                    data:seriesData,
                    itemStyle:{
                        barBorderRadius:10
                    },
                    silent:true,
                    yAxisIndex:0,
                    zlevel:1
                },
                {
                    type:'bar',
                    barWidth:barWidth,
                    data:seriesData1,
                    itemStyle:{
                        barBorderRadius:10,
                        color: {image: PatternImgA,repeat: 'repeat'}
                    },
                    yAxisIndex:1,
                    zlevel:2
                },{
                    type:'bar',
                    barWidth:barWidth,
                    data:bgseriesData,
                    itemStyle:{
                        barBorderRadius:10,
                        color: 'rgba(81,190,204,.3)'
                    },
                    xAxisIndex:1,
                    yAxisIndex:2,
                    zlevel:0,
                    silent:true,
                    label:{
                        show:true,
                        formatter:function(se){
                            var value=se.data.value1;
                            var flag=se.data.flagPre,
                                numStyle,
                                pre=se.data.pre;
                            if(flag==0){
                                numStyle='upValue';
                            }else if(flag==1){
                                numStyle='downValue';
                            }else if(flag==2){
                                numStyle='sameValue';
                            }
                            var str='{value|'+value+'}{'+numStyle+'|'+pre.toFixed(0)+'%}{'+flag+'|}';
                            return str;

                        },
                        position:'right',
                        color:'#fff',
                        rich:{
                            value:{
                                color:'#fff',
                                fontSize:14,
                                padding:[0,3,0,7],
                                width:numwidth
                            },
                            upValue:{
                                color:'#e6676f',
                                fontSize:14,
                                padding:[0,3,0,3],
                                width:prewidth
                            },
                            downValue:{
                                color:'#71f283',
                                fontSize:14,
                                padding:[0,3,0,3],
                                width:prewidth
                            },
                            sameValue:{
                                color:'#3ecefe',
                                fontSize:14,
                                padding:[0,3,0,3],
                                width:prewidth
                            },
                            0:{
                                height: 11,
                                align: 'center',
                                backgroundColor: {
                                    image: flagImage['0']
                                }
                            },
                            1:{
                                height: 11,
                                align: 'center',
                                backgroundColor: {
                                    image: flagImage['1']
                                }
                            },
                            2:{
                                height: 11,
                                align: 'center',
                                backgroundColor: {
                                    image: flagImage['2']
                                }
                            }
                        }
                    }

                }
            ]
        };
        var BarOption=this.extendOption(defaultBar2Option,settingOpt);
        return BarOption;
    },
    getBar3Option:function(data){
        var legendDate=this.getLegend(data.series),
            seriesData=data.series,
            l=seriesData.length,me=this;
        if(!data.color){
            data.color=defaultBar3Option.color;
        }
        for(var i=0;i<l;i++){
            seriesData[i].type='bar';
            seriesData[i].stack='总量';
            seriesData[i].barWidth='22%';
            seriesData[i].itemStyle={
                color:{
                    type: 'linear',
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    colorStops: [{
                        offset: 0, color: linerColor[data.color[i]][0] // 0% 处的颜色
                    }, {
                        offset: .7, color:  linerColor[data.color[i]][1] // 80% 处的颜色
                    }, {
                        offset: 1, color:  linerColor[data.color[i]][2] // 100% 处的颜色
                    }],
                    globalCoord: false // 缺省为 false
                }
            };
        }
        var settingOpt={
            legend:{
                data:legendDate,
                left:80,
                right:0
            },
            grid:[{
                top:50
            }],
            xAxis:data.xAxis,
            yAxis:data.yAxis,
            series:seriesData,
            tooltip:{
                formatter:function(params, ticket, callback){
                    var xAxisName=params[0].axisId,html='<span style="font-size: 16px;">'+params[0].axisValue+'</span>',
                        l=params.length;
                    if(xAxisName.indexOf('series')==-1){
                        html+=xAxisName.substring(0,xAxisName.length-1);
                    }
                    var totalNum=0;
                    //获得总数
                    for(var j=0;j<l;j++){
                        totalNum+=params[j].data;
                    }

                    for(var i=l-1;i>=0;i--){
                        var percent=((params[i].value/totalNum)*100).toFixed(1);
                        html+='<div style=""><span class="tooltipCir" style="background-color:'+params[i].color.colorStops[0].color+'"></span>'+params[i].seriesName+'：'+me.formatNum(params[i].value)+'，占'+percent+'%</div>';
                    }
                    return html;
                }
            }
        };

        if(legendDate.length==1){
            settingOpt.legend.show=false;
        }
        var BarOption=this.extendOption(defaultBar3Option,settingOpt);
        if(data.color){
            BarOption.color=data.color;
        }
        if(data.yAxis[0]){
            if(data.yAxis[0].type){
                BarOption.yAxis[0].type=data.yAxis[0].type;
            }
        }

        return BarOption;
    },
    getBarLineOption:function(data){
        var thisColor=['#3fa4ff','#f66673','#ffdc68'];
        var legendDate=this.getLegend(data.series),
            seriesData=data.series,
            l=seriesData.length,color={
                color:{
                    type: 'linear',
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    colorStops: [{
                        offset: 0, color: '#3eceff' // 0% 处的颜色
                    }, {
                        offset: .7, color: '#3fa4ff' // 80% 处的颜色
                    }, {
                        offset: 1, color: '#3fa4ff' // 100% 处的颜色
                    }],
                    globalCoord: false // 缺省为 false
                }
            };
        if(l>0){
            seriesData[0].type='bar';
            seriesData[0].barWidth='40%';
            seriesData[0].itemStyle=color;

            for(var i=1;i<l;i++){
                seriesData[i].type='line';
                seriesData[i].symbol='circle';
                seriesData[i].symbolSize=6;
                seriesData[i].itemStyle={
                    color:thisColor[i]
                };
            }
        }
        var settingOpt={
            legend:{
                data:legendDate
            },
            xAxis:{
                data:data.xAxis.data
            },
            series:seriesData
        };
        var BarLineOption=this.extendOption(defaultBarLineOption,settingOpt);
        return BarLineOption;

    },
    getLineOption:function(data){
        var legendDate=this.getLegend(data.series),
            seriesData=data.series,
            l=seriesData.length;
        if(!data.color){
            data.color=defaultLineOption.color;
        }
        for(var i=0;i<l;i++){
            seriesData[i].type='line';
            seriesData[i].symbol='circle';
            seriesData[i].symbolSize=6;
            seriesData[i].smooth =true;
            var areaStyle;
            if(seriesData[i].areaStyle){
                areaStyle=seriesData[i].areaStyle;
            }else{
                areaStyle={
                    color:{
                        type: 'linear',
                        x: 0,
                        y: 0,
                        x2: 0,
                        y2: 1,
                        colorStops: [
                            {offset: 0, color:opacityColor[data.color[i]][0]}, //0%
                            {offset:.3,color:opacityColor[data.color[i]][1]}, //0%
                            {offset: 1,color:opacityColor[data.color[i]][2]} //100%
                        ]
                    }
                };
            }

            seriesData[i].areaStyle=areaStyle;
            seriesData[i].emphasis={
                borderColor: defaultOption.color[i].colorRgb(),
                borderWidth: 12
            };

        }
        //data.yAxis[0].boundaryGap=['20%', '20%'];
        if(data.yAxis.length>1){
            data.yAxis[1]=this.extendOption(defaultLineOption.yAxis[0],data.yAxis[1]);
            data.yAxis[0].boundaryGap=['0','100%'];
            data.yAxis[1].boundaryGap=['0','100%'];
            data.yAxis[1].inverse=true;
            data.yAxis[1].nameLocation='start';

        }
        var settingOpt={
            legend:{
                data:legendDate
            },
            grid:[{
                left: '3%',
                right: 34,
                bottom: '2%',
                top:35,
                containLabel: true
            }],
            xAxis:{
                data:data.xAxis[0].data,
                boundaryGap:false,
                name:data.xAxis.name
            },
            yAxis:data.yAxis,
            series:seriesData
        };

        if(legendDate.length==1){
            settingOpt.legend.show=false;
        }

        var LineOption=this.extendOption(defaultLineOption,settingOpt);
        if(data.color){
            LineOption.color=data.color;
        }
        if(l>3){
            LineOption.grid.top=55;
         }
        return LineOption;
    },
    getPieOption:function(data){
        var pieOption={
            series:{
                data:data.series[0].data
            }
        };
        var newo=this.extendOption(defaultPieOption,pieOption);
        if(data.color){
            newo.color=data.color
        }
        return newo;
    },
    getTowBarLineOption:function(data){
        var legendDate=this.getLegend(data.series),
            seriesData=data.series,dataColor=data.color||defaultOption.color,
            l=seriesData.length;

        for(var i=0;i<l;i++){
            if(i<2){
                seriesData[i].type='line';
                seriesData[i].symbol='circle';
                seriesData[i].symbolSize=6;
                seriesData[i].itemStyle={
                    color:dataColor[i]
                };
                seriesData[i].yAxisIndex=1;

            }else if(i<4){
                seriesData[i].type='bar';
                seriesData[i].barWidth='25%';
                seriesData[i].barGap='20%';
                seriesData[i].itemStyle=seriesData[i].itemStyle={
                    color:{
                        type: 'linear',
                        x: 0,
                        y: 0,
                        x2: 0,
                        y2: 1,
                        colorStops: [{
                            offset: 0, color: linerColor[dataColor[i]][0] // 0% 处的颜色
                        }, {
                            offset: .7, color:  linerColor[dataColor[i]][1] // 80% 处的颜色
                        }, {
                            offset: 1, color:  linerColor[dataColor[i]][2] // 100% 处的颜色
                        }],
                        globalCoord: false // 缺省为 false
                    }
                };
            }else{
                seriesData[i].type='custom';
                seriesData[i].tooltip={formatter:'{b0}: {c0}<br />{b1}: {c1}'};
                seriesData[i].itemStyle={
                    color:dataColor[i]
                };
                seriesData[i].renderItem=function(){
                    return {};
                };
            }
        }
        legendDate=this.getLegend(seriesData);
        if(data.yAxis.length>1){
            var defaultyAxis=this.deepClone(defaultLineOption.yAxis[0]);
            data.yAxis[1]=this.extendOption(defaultyAxis,data.yAxis[1]);
            data.yAxis[1].nameLocation='start';
            data.yAxis[0].interval= function(a){
                return 400;
            };
            data.yAxis[1]=this.extendOption(
                {
                    nameLocation:'start',
                    axisLabel:{
                        formatter:'{value} %'
                    }
                },
                data.yAxis[1]);
        }
        var settingOpt={
            legend:{
                data:legendDate
            },
            tooltip:{
               /* formatter:'{b}<br />{a0}: {c0}%' +
                '<br />{a1}: {c1}%' +
                '<br />{a2}: {c2}' +
                '<br />{a3}: {c3}' +
                '<br />{a4}: {c4}%' +
                '<br />{a5}: {c5}%'*/
                padding:10,
                formatter:function(params, ticket, callback){
                    //console.log(params);
                    return params[0].axisValue+
                        '<br /><span class="tooltipCir" style="background-color:'+params[0].color+'"></span>'+params[0].seriesName+'：'+params[0].value+'%'+
                        '<br /><span class="tooltipCir" style="background-color:'+params[1].color+'"></span>'+params[1].seriesName+'：'+params[1].value+'%'+
                        '<br /><span class="tooltipCir" style="background-color:'+params[2].color.colorStops[0].color+'"></span>'+params[2].seriesName+'：'+params[2].value+''+
                        '<br /><span class="tooltipCir" style="background-color:'+params[3].color.colorStops[0].color+'"></span>'+params[3].seriesName+'：'+params[3].value+''+
                        '<br /><span class="tooltipCir" style="background-color:'+params[4].color+'"></span>'+params[4].seriesName+'：'+params[4].value+'%'+
                        '<br /><span class="tooltipCir" style="background-color:'+params[5].color+'"></span>'+params[5].seriesName+'：'+params[5].value+'%';
                }
            },
            grid:{
                left: '3%',
                right: '5%',
                bottom: '2%',
                top:55,
                containLabel: true
            },
            xAxis:{
                data:data.xAxis.data,
                //boundaryGap:false,
                name:data.xAxis.name,
                showMinLabel:true
            },
            series:seriesData,
            yAxis:data.yAxis
        };

        var towLineBarOption=this.extendOption(settingOpt,defaultBarLineOption);
        return towLineBarOption;
    },
    echartTowPieOpt:function(data){
        var series=this.deepClone(data.series[0]);
        //排序
        series.data=(series.data).sort(function(a,b){
            return b.value- a.value;
        });
        var total=series.data[0].value+series.data[1].value,
            pre1=(series.data[0].value/total)*100,
            pre2=(series.data[1].value/total)*100,pre;
        pre=pre1>pre2?pre1:pre2;
        pre=pre.toFixed(0);
        if(pre!=100){
            series.data[0].value=series.data[0].value-(total*0.018);
            series.data[1].value=series.data[1].value+(total*0.018);
        }
        series.data[1].itemStyle={
            color: 'rgba(0, 0, 0, 0)',
            borderColor: 'rgba(0, 0, 0, 0)',
            borderWidth: 0
        };
        //数据处理
        var defopt={
            color:data.color,
            tooltip : {
                trigger: 'item',
                formatter: "{b} : {c} 件 ({d}%)"
            },
            calculable:true,
            startAngle:93,
            title:[{
                x:'center',
                y:'0',
                text: data.series[0].name,
                textStyle: {
                    fontSize: 16,
                    fontWeight: 'normal',
                    color:fontColor.bottom
                }},
                {
                    x:'center',
                    y:'50%',
                    text: pre+'%',
                    textStyle: {
                        fontSize: 18,
                        fontWeight: 'normal',
                        color:fontColor.bottom
                    }
                }
            ],
            series:[
                {
                    type:'pie',
                    radius : ['62%', '67%'],
                    center : ['50%', '60%'],
                    roseType:'radius',
                    data:series.data,
                    label: {
                        normal: {
                            show: false
                        }
                    },
                    itemStyle:{
                        borderWidth: 4,
                        borderColor:new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                            offset: 0,
                            color: linerColor[data.color[0]][0]
                        }, {
                            offset: 1,
                            color: linerColor[data.color[0]][2]
                        }]),
                        color:new echarts.graphic.LinearGradient(0, 0, 1, 1, [{
                            offset: 0,
                            color: linerColor[data.color[0]][0]
                        }, {
                            offset: 1,
                            color: linerColor[data.color[0]][2]
                        }])
                    }

                },
                {
                    type:'pie',
                    radius : ['46%', '49%'],
                    center : ['50%', '60%'],
                    data:[1],
                    startAngle:90,
                    label: {
                        normal: {
                            show: false
                        }
                    },
                    itemStyle:{
                        color:'#86cdf2',
                        opacity:.5
                    }
                }
            ]
        };
        return defopt;

    },
    echartMapOpt:function(data){
        var geoCoordMap={
            '福州市':[119.306239,25.805302],
            '平潭':[119.806239,25.575302],
            '莆田市':[118.902558,25.331011],
            '龙岩市':[116.72978,25.091603],
            '厦门市':[118.11022,24.490474],
            '漳州市':[117.361801,24.210897],
            '南平市':[118.178459,27.535627],
            '三明市':[117.335001,26.265444],
            '宁德市':[119.827082,27.05924],
            '泉州市':[118.489421,25.008853],
            '省平台':[119.000,26.40900]
        };
        var coneGeo=this.deepClone(geoCoordMap);
        var spName='省平台';
        var planePath = 'path://M14.367,28.444 L11.003,67.087 L7.600,28.437 L0.014,28.429 L10.675,0.008 L21.298,28.452 L14.367,28.444 Z';

        function convertData(data) {
            var res = [];
            for (var i = 0; i < data.length; i++) {
                var geoCoord = geoCoordMap[data[i].name];
                if (geoCoord) {
                    var tepdata={
                        name: data[i].name,
                        value: geoCoord.concat(data[i].value)
                    };
                    if(tepdata.name=='省平台'){
                        tepdata.label={
                            position:'right'
                        };
                        tepdata.symbolSize=15;
                        tepdata.symbol='path://M1077.529145 388.206248C1072.06379 371.533456 1056.511742 360.326019 1039.008769 360.326019L686.956883 360.326019 578.161726 27.824884C572.876243 11.207437 557.37954 0 539.765877 0 522.262904 0 506.710856 11.207437 501.370028 27.700357L392.450343 360.326019 40.467639 360.326019C22.909321 360.326019 7.398781 371.533456 2.002608 388.206248-3.462747 404.713004 2.528389 422.963139 16.682967 433.119014L301.504067 638.533348 192.764255 971.214355C187.243555 987.776457 193.234691 1005.860556 207.444614 1016.127121 221.474665 1026.338342 240.845544 1026.338342 254.944776 1016.127121L539.765877 810.588261 824.642322 1016.127121C831.629675 1021.191223 839.972989 1023.820128 848.371649 1023.820128 856.701127 1023.820128 865.099787 1021.191223 872.142485 1016.127121 886.297062 1005.860556 892.288199 987.776457 886.767498 971.214355L778.138377 638.533348 1062.793441 433.119014C1076.934183 422.963139 1082.869974 404.713004 1077.529145 388.206248Z';
                        tepdata.itemStyle={
                            color:'#ff3d3d',
                            borderColor:'#ff3d3d'
                        }
                    }
                    res.push(tepdata);
                }
            }
            return res;
        }
        function coverLinesData(data){
            var res = [];
            for (var i = 0; i < data.length; i++) {
                var dataItem = data[i],fromName=dataItem['fromName'],toName=dataItem['toName'];
                var fromCoord = geoCoordMap[fromName];
                var toCoord = geoCoordMap[toName];

                if (fromCoord && toCoord) {
                    dataItem.coords=[fromCoord, toCoord];
                    dataItem.effect={
                        show: true,
                        period: 6,
                        trailLength:.5,
                        symbol: planePath,
                        symbolSize: [10,30]
                    };
                    if(fromName==spName){
                        dataItem.effect.color='#ffda8a';
                    }else{
                        dataItem.effect.color='#ef4c3a';
                    }
                    res.push(dataItem);
                }

                //剔除有数据的连线
                if(coneGeo[fromName]){
                    delete coneGeo[fromName];
                }
                if(coneGeo[toName]){
                    delete coneGeo[toName];
                }
            }

            return {res:res,coneGeo:coneGeo};
        }

        var sData=this.deepClone(data.series[0].data);//深度复制
        sData=this.sortData(sData);

        //地图背景设置
        for(var j=0;j<sData.length;j++){
            var tempD=sData[j];
           /* tempD.itemStyle={
                color:'rgba(128, 128, 128,0)'
            };*/
            switch(tempD.name){
                case '龙岩市':
                    tempD.itemStyle={
                        color: {
                            type: 'linear',
                            x: 0,
                            y: 0,
                            x2:0,
                            y2: 1,
                            colorStops: [{
                                offset: 0, color: '#103fa3' // 0% 处的颜色
                            }, {
                                offset: 1, color: '#1754b7' // 100% 处的颜色
                            }],
                            globalCoord: false // 缺省为 false
                        }
                    };
                    break;

                case '漳州市':
                    tempD.itemStyle={
                        color: {
                            type: 'linear',
                            x: 0,
                            y: 0,
                            x2: 0,
                            y2: 1,
                            colorStops: [{
                                offset: 0, color: '#0e379d' // 0% 处的颜色
                            }, {
                                offset: 1, color: '#1347ac' // 100% 处的颜色
                            }],
                            globalCoord: false // 缺省为 false
                        }
                    };
                    break;
                case '三明市':
                    tempD.itemStyle={
                        color: {
                            type: 'linear',
                            x: 0,
                            y: 0,
                            x2: 0,
                            y2: 1,
                            colorStops: [{
                                offset: 0, color: '#154db1' // 0% 处的颜色
                            }, {
                                offset: 1, color: '#1c64c7' // 100% 处的颜色
                            }],
                            globalCoord: false // 缺省为 false
                        }
                    };
                    break;
                case '厦门市':
                    tempD.itemStyle={
                        color: {
                            type: 'linear',
                            x: 0,
                            y: 0,
                            x2: 0,
                            y2: 1,
                            colorStops: [{
                                offset: 0, color: '#103fa3' // 0% 处的颜色
                            }, {
                                offset: 1, color: '#1243a8' // 100% 处的颜色
                            }],
                            globalCoord: false // 缺省为 false
                        }
                    };
                    break;
                case '泉州市':
                    tempD.itemStyle={
                        color: {
                            type: 'linear',
                            x: 0,
                            y: 0,
                            x2: 0,
                            y2: 1,
                            colorStops: [{
                                offset: 0, color: '#1140a5' // 0% 处的颜色
                            }, {
                                offset: 1, color: '#1752b6' // 100% 处的颜色
                            }],
                            globalCoord: false // 缺省为 false
                        }
                    };
                    break;
                case '莆田市':
                    tempD.itemStyle={
                        color: {
                            type: 'linear',
                            x: 0,
                            y: 0,
                            x2: 0,
                            y2: 1,
                            colorStops: [{
                                offset: 0, color: '#1348ac' // 0% 处的颜色
                            }, {
                                offset: 1, color: '#1650b3' // 100% 处的颜色
                            }],
                            globalCoord: false // 缺省为 false
                        }
                    };
                    break;
                case '福州市':
                    tempD.itemStyle={
                        color: {
                            type: 'linear',
                            x: 0,
                            y: 0,
                            x2: 0,
                            y2: 1,
                            colorStops: [{
                                offset: 0, color: '#144cb0' // 0% 处的颜色
                            }, {
                                offset: 1, color: '#1a5ec1' // 100% 处的颜色
                            }],
                            globalCoord: false // 缺省为 false
                        }
                    };
                    break;
                case '宁德市':
                    tempD.itemStyle={
                        color: {
                            type: 'linear',
                            x: 0,
                            y: 0,
                            x2: 0,
                            y2: 1,
                            colorStops: [{
                                offset: 0, color: '#1959bd' // 0% 处的颜色
                            }, {
                                offset: 1, color: '#1e6ace' // 100% 处的颜色
                            }],
                            globalCoord: false // 缺省为 false
                        }
                    };
                    break;
                case '南平市':
                    tempD.itemStyle={
                        color: {
                            type: 'linear',
                            x: 0,
                            y: 0,
                            x2: 0,
                            y2: 1,
                            colorStops: [{
                                offset: 0, color: '#1a5cbe' // 0% 处的颜色
                            }, {
                                offset: 1, color: '#2070d2' // 100% 处的颜色
                            }],
                            globalCoord: false // 缺省为 false
                        }
                    };
                    break;
            }

        }

        var maxValue=sData[0].value,maxSize=25,minSize= 5,
            lineDataObj=coverLinesData(data.series[0].lines);
        var resData=convertData(sData),
            lineData=lineDataObj.res,
            noLineData=[];
        coneGeo=lineDataObj.coneGeo;

        //构造无数据lines
        for(var key in coneGeo){
            var fromCoord = geoCoordMap[spName];
            var toCoord = geoCoordMap[key];
            noLineData.push({
                name:spName+'-'+key,
                fromName:spName,
                toName:key,
                value:10,
                coords:[fromCoord,toCoord],
                effect:{
                    symbolSize: 0,
                    color:'rgba(255,255,255,0)'
                }
            });
        }
        lineData=lineData.concat(noLineData);
        var curveness={//区县曲线方向弧度
            '宁德市':{fromcurveness:0.1,tocurveness:-0.1},
            '南平市':{fromcurveness:0.4,tocurveness:-0.4},
            '三明市':{fromcurveness:0.25,tocurveness:-0.25},
            '龙岩市':{fromcurveness:0.3,tocurveness:-0.3},
            '漳州市':{fromcurveness:0.3,tocurveness:-0.3},
            '厦门市':{fromcurveness:0.3,tocurveness:-0.3},
            '泉州市':{fromcurveness:0.3,tocurveness:-0.3},
            '莆田市':{fromcurveness:0.2,tocurveness:-0.2},
            '福州市':{fromcurveness:-0.4,tocurveness:0.4},
            '平潭':{fromcurveness:-0.3,tocurveness:0.3}
        };
        for(var i=0;i<lineData.length;i++){
            //线条处理
            var tempD=lineData[i];
            if(curveness[tempD.fromName]){
                tempD.lineStyle={
                    curveness:curveness[tempD.fromName].fromcurveness
                };
            }
            if(curveness[tempD.toName]){
                tempD.lineStyle={
                    curveness:curveness[tempD.toName].tocurveness
                };
            }
        }
        var thisOption={
            series:[{
                data:resData,
                symbolSize:function(value) {
                    var p = value[2] / maxValue, size;
                    size = p * maxSize;
                    if (size <= minSize) {
                        size = minSize;
                    }
                    return size
                }
            },{
                data:sData,
                left:0
            },{
                type:'lines',
                data:lineData,
                zlevel: 2,
                effect: {
                    show: true
                }
            },{
                data:data.series[0].data
            },
                {
                    name:'地图阴影',
                    mapType:'FZ',
                    type:'map',
                    geoIndex:2,
                    aspectScale:1,
                    center:[118.1039,26.990],
                    data:data.series[0].data,
                    itemStyle:{
                        areaColor:'rgb(30,49,108)',
                        borderWidth:7
                    },
                    zlevel:7
                }
            ]
        };

        var mapOption=this.extendOption(defaultMapOption,thisOption);
        return mapOption;
    },
    echartSetOpt:function(id,opt){
        var echartsInstance=echarts.init(document.getElementById(id),'customed');
        echartsInstance.setOption(opt);
        return echartsInstance;
    },
    isSmall:function(){
        var w=$(window).width();
        if(w<768){
            return true;
        }else {
            return false;
        }
    },

    refreshLiquidFill:function(echartsIns,data1){
        var data=data1.series;
        var val1=data[0].data[0].value,val2=data[0].data[1].value,
            pre=(Math.floor((val1/(val1+val2)*100))/100).toFixed(2);
        val1=(toMoney(val1)).join('');
        echartsIns.setOption({
            title:{
                subtext:val1
            },
            series: [{
                type: 'liquidFill',
                data: [pre]
            }]
        });

    },
    echartPieInit:function(id,data){
        var opt=this.getPieOption(data);
        var pitInt=this.echartSetOpt(id,opt);
        pitInt.on('click',function(obj){
            pitInt.dispatchAction({
                type: 'highlight',
                dataIndex:obj.dataIndex
            })
        });
        return pitInt;
    },

    echartPieIndexInit:function(id,data){
        this.setPieHeight(id);
        var me=this;
        var opt=this.getPieIndexOption(data);
        var pitInt=this.echartSetOpt(id,opt);
        pitInt.chartType='pie';
        pitInt.on('mouseover',function(param){
            if(param.seriesIndex==0){
                var childIndex=param.data.childIndex,l=childIndex.length;
                var action=[];
                for(var i=0;i<l;i++){
                    action.push({dataIndex:childIndex[i]*2,seriesIndex:1});
                }
                console.log(childIndex);
                pitInt.dispatchAction({
                    type: 'highlight',
                    batch:action
                });
            }

        });
        pitInt.on('mouseout',function(param){
            if(param.seriesIndex==0){
                var childIndex=param.data.childIndex,l=childIndex.length;
                var action=[];
                for(var i=0;i<l;i++){
                    action.push({dataIndex:childIndex[i]*2,seriesIndex:1});
                }
                console.log(childIndex);
                pitInt.dispatchAction({
                    type: 'downplay',
                    batch:action
                });
            }

        });
        $(window).resize(function(){
            me.setPieHeight(id);
        });
        return pitInt;
    },
    echartPie2Init:function(id,data){
        this.setPieHeight(id);
        var opt=this.getPie2Option(data),me=this;
        var pitInt=this.echartSetOpt(id,opt);
        pitInt.chartType='pie2';
        $(window).resize(function(){
            me.setPieHeight(id);
        });
        return pitInt;
    },
    echartPie3Init:function(id,data){
        var opt=this.getPie3Option(data);
        var pitInt=this.echartSetOpt(id,opt),me=this,thisT;
        pitInt.on('mouseover',function(param){
            clearTimeout(thisT);
            if(param.seriesIndex==0){
                me.noHightOnePie(pitInt,4);
                clearInterval(pitInt.inter);
                var childIndex=param.data.childIndex,l=childIndex.length;
                var action=[];
                for(var i=0;i<l;i++){
                   action.push({dataIndex:childIndex[i]*2,seriesIndex:1});
                }
                action.push({
                    seriesIndex:0,
                    dataIndex:param.dataIndex
                });
                pitInt.dispatchAction({
                    type: 'pieSelect',
                    batch:action
                });
            }
        });
        pitInt.on('mouseout',function(param){
            clearTimeout(thisT);
            if(param.seriesIndex==0){
                var childIndex=param.data.childIndex,l=childIndex.length;
                var action=[];
                for(var i=0;i<l;i++){
                    action.push({dataIndex:childIndex[i]*2,seriesIndex:1});
                }
                console.log(childIndex);
                action.push({
                    seriesIndex:0,
                    dataIndex:param.dataIndex
                });
                pitInt.dispatchAction({
                    type: 'pieUnSelect',
                    batch:action
                });

                thisT=setTimeout(function(){
                    me.interPie3Init(pitInt,5000,pitInt.beginIndex);
                },200);

               // me.interPie3Init(pitInt,5000,pitInt.beginIndex);

            }

        });
        pitInt.on('globalout',function(){
            //me.interPie3Init(pitInt,5000,pitInt.beginIndex);
        });
        pitInt.chartType='pie3';
        return pitInt;
    },
    interPie3Init:function(echartsIns,dur,beginIndex){
        var interIndex= beginIndex||0,indexLength= 4,me=this;
        dur=dur||5000;
        //清除循环
        clearInterval(echartsIns.inter);
        //第一次
        me.interOnePie(echartsIns,interIndex,indexLength);
        echartsIns.beginIndex=interIndex;
        interIndex++;
        //开启循环
        var t=setInterval(function(){

            me.interOnePie(echartsIns,interIndex,indexLength);

            echartsIns.beginIndex=interIndex;
            interIndex++;
            if(interIndex>=indexLength){
                interIndex=0;
            }
        },dur);
        echartsIns.inter=t;
        echartsIns.interIndex=interIndex;
    },
    interOnePie:function(echartsIns,interIndex,indexLength){
        var opt=echartsIns.getOption(),s1=opt.series[0];
        var l1=s1.data.length,action=[],daction=[];
        for(var i=0;i<l1;i++){
            var index=(interIndex+i*indexLength)*2;
            action.push({
                seriesIndex:1,
                dataIndex:index
            });
            if(interIndex>0&&interIndex<indexLength){
                daction.push({
                    seriesIndex:1,
                    dataIndex:index-2
                });
            }else{
                 daction.push({
                     seriesIndex:1,
                     dataIndex:index+2*(indexLength-1)
                 });

            }
        }
        echartsIns.dispatchAction({
            type: 'highlight',
            batch:action
        });
        echartsIns.dispatchAction({
            type: 'downplay',
            batch:daction
        });
    },
    noHightOnePie:function(echartsIns,indexLength){
        var interIndex=echartsIns.beginIndex;
        var opt=echartsIns.getOption(),s1=opt.series[0];
        var l1=s1.data.length,action=[];
        for(var i=0;i<l1;i++){
            var index=(interIndex+i*indexLength)*2;
            action.push({
                seriesIndex:1,
                dataIndex:index
            });
        }
        echartsIns.dispatchAction({
            type: 'downplay',
            batch:action
        });
    },
    echartBarIndexInit:function(id,data,dur){
        //默认排序

        var opt=this.getBarOption(data,1),ins=this.echartSetOpt(id,opt),me=this;
        ins.chartType='bar';
        ins.originData=data;
        var newOpt=ins.getOption(),series=newOpt.series;
        if($('#'+id).find('.button-g').length>0){
            $('#'+id).find('.button-g').remove();
        }
        var $ledege=$('<div class="button-g"></div>'),$button;
        for(var i=0;i<series.length;i++){
            $button=$('<div class="button button'+(i+1)+'"><div class="border">'+series[i].name+'<i></i></div></div');
            $ledege.append($button);
        }
        $ledege.find('.button').each(function(index){
            var a=index;
            $(this).click(function(){
                if(!$(this).hasClass('hover')){
                    $(this).addClass('hover');
                    $(this).siblings().removeClass('hover');
                    //me.intervelBar(ins,ins.interdur);
                    me.echartBartSort(id,a);
                    //下一个计时
                    me.intervelBar(ins,ins.interdur);
                }
            });
        });
        $('#'+id).append($ledege);
        dur=dur||5000;
        me.intervelBar(ins,dur);
        me.barButtonInit(id,0);
        return ins;
    },
    intervelBar:function(echartsIns,dur){
        var id=echartsIns.getDom().id,me=this,
            $button_g=$('#'+id).find('.button-g'), $button_hover;
        clearInterval(echartsIns.inter);
        var t=setInterval(function(){
            $button_hover=$button_g.find('.button.hover');
            var index=$button_hover.siblings().index();
            me.barButtonInit(id,index);
            me.echartBartSort(id,index);
        },dur);
        echartsIns.inter=t;
        echartsIns.interdur=dur;
    },
    barButtonInit:function(id,i){
         var  $button_g=$('#'+id).find('.button-g'),
             $button_hover=$button_g.find('.button').eq(i);
        $button_hover.addClass('hover');
        $button_hover.siblings().removeClass('hover');
    },
    echartBartSort:function(id,i){
        var me=this,ins=echarts.getInstanceByDom($('#'+id)[0]);
        var originData=ins.originData,
            opt=me.barSort(originData,i);
        opt=me.getBarOption(opt);
        ins.setOption(opt);
    },
    //数据排序
    barSort:function(sdata,i){
        var data=sdata.series,temD=[],data1,me=this;
        function change(data,index1,index2){
            data[index1].data=me.sortData(data[index1].data);
            data1=data[index2].data;
            var l=data[index1].data.length;
            for(var j=0;j<l;j++){
                var l1=data1.length;
                for(var k=0;k<l1;k++){
                    if(data[index1].data[j].name==data1[k].name){
                        temD.push(data1[k]);
                        break;
                    }
                }

            }
            data[index2].data=temD;
            var leData=me.getYAxis(data[index1].data);
            var newData={
                yAxis:[{data:leData}],
                series:[
                    {name:data[0].name, data:data[0].data},
                    {name:data[1].name, data:data[1].data}
                ]
            };
            return newData;
        }
        if(i==0){
            data=change(data,0,1);
        }else{
            data=change(data,1,0);
        }
        return data;
    },
    getThisIndex:function(id){
        var $button_hover=$('#'+id).find('.button-g .button.hover');
        return $button_hover.index();
    },
    getYAxis:function(data){
        var l=data.length,lname=[];
        for(var j=0;j<l;j++){
            lname.push(data[j].name);
        }
        return lname;
    },
    echartBar2Init:function(id,data){
        var opt=this.getBar2Option(data);
        var ins=this.echartSetOpt(id,opt);
        ins.chartType='bar2';
        return ins;
    },
    echartBarInit:function(id,data){
        var opt=this.getBar3Option(data);
        var ins=this.echartSetOpt(id,opt);
        ins.chartType='bar3';
        return ins;
    },
    echartSortInit:function(id,data) {
        var str = '', sData = this.deepClone(data.series[0].data),
            l = sData.length;
        str += '<div class="sortData"><ul class="sort">';
        for (var i = 0; i < l; i++) {
            var tempD = sData[i];
            str += this.getOneShtml(tempD, i + 1);
            if (i == 4 && l > 4) {
                str += '</ul><ul class="sort">';
            }
        }
        str += '</ul></div>';
        $('#' + id).html(str);

        return {id: id, chartType: 'tablesort',setOption:function(){}};
    },
    getOneShtml:function(oneDate,i){
        var flag=oneDate.flagNum,flagClass='up',num='';
        if(flag==0||flag=='0'){
            flagClass='up'
        }else if(flag==1||flag=='1'){
            flagClass='down'
        }else{
            flagClass='same'
        }
        if(oneDate.num>1){
            num=oneDate.num;
        }
        var html='<li> <div class="li_wrapper"> <i class="icon icon-'+i+'">'+i+'</i>' +
            ' <span class="name">'+oneDate.name+'</span> <span class="value">'+oneDate.value+'</span> ' +
            '<span class="flag"><img src="images/'+flagClass+'.png"></span> <span class="flagnum  '+flagClass+'">'+num+'</span> </div> </li>';
        return html;
    },
    treeInfoInit:function(id,data){
        var str='',sData=this.deepClone(data.series[0].data),
            l=sData.length;
        var titleData=sData[0],
            titleHtml='<div class="title"> <ul class="title-ul"> <li>全省总共单位<span class="font-c">'+titleData.value+'</span>家</li> <li>覆盖单位用户<span class="font-c">'+titleData.userValue+'</span>人</li> </ul> </div>',
            treeHtml=titleHtml+'<div class="tree"><div class="tree-con"><ul>';
        for(var i=1;i<l;i++){
            var tempD=sData[i];
            var liHtml='<li> <div class="info info'+i+'"> <div class="text"> <div>'+tempD.name+'</div> ' +
                '<div>'+tempD.value+'家</div>  </div> </div> <svg class="svg svgbg-'+i+'"> <use xlink:href="#t'+i+'"></use> </svg> </li>';
            treeHtml+=liHtml;
        }
        treeHtml+='</ul></div><div class="bottom"> <div class="line"></div> </div></div>';
        $('#'+id).html(treeHtml);
        return {id: id, chartType: 'treeinfo',setOption:function(){}};
    },

    echartBarLineInit:function(id,data){
        var opt=this.getBarLineOption(data);
        return this.echartSetOpt(id,opt);
    },
    echartLineInit:function(id,data){
        var opt=this.getLineOption(data);
        return this.echartSetOpt(id,opt);
    },
    echartTowPieInit:function(id,data){
        var opt=this.echartTowPieOpt(data);
        var ins=this.echartSetOpt(id,opt);
        ins.chartType='piering';
        return ins;
    },
    echartMapInit:function(id,data){
        var opt =this.echartMapOpt(data);
        $('#'+id).addClass('animate');
        $('.sp-border').addClass('animate');
        $('.map-bottom').addClass('animate');
        return this.echartSetOpt(id,opt);
    },

    echartTBarLineInit:function(id,data){
        var opt =this.getTowBarLineOption(data);
        return this.echartSetOpt(id,opt);
    },
    getTreeMapOption:function(data){
        var newdata=this.deepClone(data.series[0].data);
        var newColor=data.color;
        if(!newColor){
            newColor=['#31a7fc','#61dbb0','#ff9650','#e7cb5c','#4ad48c','#da6c3b','#d24a4c'];
        }
        for(var i=0;i<newdata.length;i++){
            newdata[i].itemStyle={
                color:{
                    type: 'linear',
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    colorStops: [{
                        offset: 0, color: linerColor[newColor[i]][0] // 0% 处的颜色
                    }, {
                        offset: .5, color:  linerColor[newColor[i]][1] // 80% 处的颜色
                    }, {
                        offset: 1, color:  linerColor[newColor[i]][2] // 100% 处的颜色
                    }],
                    globalCoord: false // 缺省为 false
                }
            }
        }
        var defaultO={
                tooltip:{
                    trigger:'item',
                    formatter:function(param){
                        if(param.name){
                            return '<span class="tooltipCir" style="background-color: '+param.color.colorStops[0].color+'"></span>'+param.name+'：'+param.value+'件';
                        }

                    }
                },
                animation:true,
                series: [{
                    left:20,
                    right:20,
                    width:'95%',
                    height:'90%',
                    name:'',
                    roam:false,
                    type: 'treemap',
                    data:newdata,
                    itemStyle: {
                        normal: {
                            gapWidth:10,
                            borderColor:'rgba(255,255,255,0)'
                        }
                    },
                    label:{
                        formatter: [
                            '{a|{b}}',
                            '{b|{c}件}'
                        ].join('\n'),
                        fontSize:20,
                        fontWeight:'100',
                        align:'center',
                        distance:0,
                        rich: {
                            a: {
                                fontSize:20,
                                color:'#fff',
                                lineHeight: 35
                            }
                        }
                    },
                    breadcrumb:false,
                    nodeClick:false,
                    animationDelay:1000,
                    animationDuration:2000
                }]
        };
        return defaultO;
    },
    echartTreeMapInt:function(id,data){
        var opt =this.getTreeMapOption(data);
        return this.echartSetOpt(id,opt);
    },
    IntervalIns:function(echartsIns,dur,callback){
        clearInterval(echartsIns.inter);
        echartsIns.setOption({
            tooltip:{
                triggerOn:'none'
            }
        });
        var s = echartsIns.getOption().series[0];
        var i= 1,l=s?(s.data?echartsIns.getOption().series[0].data.length:0):0,
            d=dur?dur:4000,me=this;
        setTimeout(function(){
            me.intervalOne(echartsIns,d,0,l,callback);
        },10);

        var t=setInterval(function(){
            me.intervalOne(echartsIns,dur,i,l,callback);
            i++;
            if(i>=l){
                i=0;
            }
        },dur);

        echartsIns.inter=t;
        echartsIns.on('mouseover',function(a,b){
            echartsIns.setOption({
                tooltip:{
                    triggerOn:'none'
                }
            });
            clearInterval(echartsIns.inter);

            echartsIns.dispatchAction({
                type: 'downplay',
                batch: [{
                    dataIndex: i-1,
                    seriesIndex:0
                }, {
                    dataIndex: i-1,
                    seriesIndex:1
                }]
            });
            i= a.dataIndex;
            echartsIns.dispatchAction({
                type: 'highlight',
                dataIndex: i,
                seriesIndex:0
            });
            echartsIns.dispatchAction(
                {
                    seriesIndex:0,
                    type: 'showTip',
                    dataIndex: i
                }
            );
        });
        echartsIns.on('mouseout',function(a,b){
            clearInterval(echartsIns.inter);
            i= a.dataIndex;
            me.intervalOne(echartsIns,d,i,l);
            i++;
            t=setInterval(function(){
                if(i>=l){
                    i=0;
                }
                me.intervalOne(echartsIns,dur,i,l,callback);
                i++;

            },dur);
            echartsIns.inter=t;
        });


    },
    intervalOne:function(echartsIns,dur,i,l,callback){
        var geo=echartsIns.getOption().geo;

        if(i==0){
            echartsIns.dispatchAction({
                type: 'downplay',
                dataIndex: l-1
            });
            if(geo){
                echartsIns.dispatchAction({
                    type: 'downplay',
                    dataIndex: l-1,
                    seriesIndex:1
                });
            }
        }else{
            echartsIns.dispatchAction({
                type: 'downplay',
                dataIndex: i-1
            });
            if(geo){
                echartsIns.dispatchAction({
                    type: 'downplay',
                    dataIndex: i-1,
                    seriesIndex:1
                });
            }
        }
        if(geo){
            echartsIns.dispatchAction({
                type: 'highlight',
                dataIndex: i,
                seriesIndex:1
            });
            echartsIns.dispatchAction(
                {
                    seriesIndex:1,
                    type: 'showTip',
                    dataIndex: i
                }
            );
        }else{
            echartsIns.dispatchAction({
                type: 'highlight',
                dataIndex: i,
                seriesIndex:0
            });
        }
        echartsIns.dispatchAction(
            {
                seriesIndex:0,
                type: 'showTip',
                dataIndex: i
            }
        );
        if(callback){
            callback(i)
        }

    },
    IntervalTowPie:function(echartsIns,dur){
        var i= 0,l=echartsIns.getOption().series[0].data.length,
            d=dur?dur:4000;
        var t=setInterval(function(){
            if(i%2==1){
                echartsIns.dispatchAction({
                    type: 'downplay',
                    dataIndex: 0
                });
                echartsIns.dispatchAction({
                    seriesIndex:0,
                    type: 'hideTip',
                    dataIndex: 0
                });
            }else{
                echartsIns.dispatchAction({
                    type: 'highlight',
                    dataIndex: 0
                });
                echartsIns.dispatchAction({
                    seriesIndex:0,
                    type: 'showTip',
                    dataIndex: 0
                });
            }

            i++;
        },dur);
    },
    clickPie:function(echartsIns,callback){
        var me=this;
        echartsIns.setOption({
            tooltip:{
                show:false,
                triggerOn:'click'
            },
            series:[{
                silent:false,
                cursor:'pointer',
                avoidLabelOverlap:false,
                hoverAnimation:false,
                minAngle:5,
                selectedMode:'single',
                label:{
                    normal:{
                        show:false,
                        position:'center',
                        color:'#fff',
                        fontSize:14
                    },
                    emphasis:{
                        show:false
                    }
                }
            }]
        });
        echartsIns.on('click',function(a){
            if(callback){
                //callback(a.name);
            }
        });
        echartsIns.on('pieselectchanged',function(params){
            me.setTip(echartsIns,params);
            if(callback){
                callback(params.name);
            }
        });
        echartsIns.off('pieselected');
        echartsIns.on('pieselected',function(params){
            me.setTip(echartsIns,params);

            if(callback){
                if(params.name){
                    callback(params.name);
                }else{
                    var name=echartsIns.getOption().series[0].data[0].name;
                    callback(name);
                }

            }
        });
    },
    setTip:function(echartsIns,params){
        var op=echartsIns.getOption(),name=params.name,data=op.series[0].data,
            id=echartsIns.getDom().id,i=0;
        var num= 0,p;
        for(i=0;i<data.length;i++){
            num+=data[i].value;
        }
        if(num==0){
            $('#'+id).find('.pieTip').remove();
            $('#'+id).append('<div class="pieTip" style="position: absolute;left:50%;top: 50%;height: 36px;margin-top:-18px;width:100px;text-align: center;margin-left:-50px;">暂无数据</div>');
        }else{
            if(name){
                for(i=0;i<data.length;i++){
                    if(name==data[i].name){
                        p=this.getPercent(data[i].value,num,true);
                        $('#'+id).find('.pieTip').remove();
                        $('#'+id).append('<div class="pieTip" style="position: absolute;left:50%;top: 50%;height: 36px;margin-top:-18px;width:100px;text-align: center;margin-left:-50px;">'
                        +data[i].name+'<br/>'+p+'</div>');
                    }
                }
            }else{
                $('#'+id).find('.pieTip').remove();
                p=this.getPercent(data[0].value,num,true);
                $('#'+id).append('<div class="pieTip" style="position: absolute;left:50%;top: 50%;height: 36px;margin-top:-18px;width:100px;text-align: center;margin-left:-50px;">'
                +data[0].name+'<br/>'+p+'</div>');
            }
        }

    },

    getPercent:function(curNum, totalNum, isHasPercentStr){
        curNum = parseFloat(curNum);
        totalNum = parseFloat(totalNum);

        if (isNaN(curNum) || isNaN(totalNum)) {
            return '-';
        }

        return isHasPercentStr ?
            totalNum <= 0 ? '0%' : (Math.round(curNum / totalNum * 10000) / 100.00 + '%') :
            totalNum <= 0 ? 0 : (Math.round(curNum / totalNum * 10000) / 100.00);
    },
    setTableData:function(id,data){
        var l=data.length,html='';
        for(var i=0;i<l;i++){
            html+=this.getTr(data[i]);
        }
        $(id+' tbody').html(html);
    },
    getTr:function(trData){
        var str='<tr>';
        for(var i=0;i<trData.length;i++){
            str+=this.getTd(trData[i]);
        }
        str+='</tr>';
        return str;
    },
    getTd:function(trData){
        if(trData){
            return '<td>'+trData+'</td>'
        }else{
            return '';
        }
    },
    animateScroll:function(id){
        $(id).stop();
        $(id).animate({scrollTop:0},0);

        var tableH=$(id+' table').height(),conH=$(id).height(),scrollTop=$(id)[0].scrollTop,h=tableH-conH-scrollTop,dur;
        if(h>0){
            dur=h/50*1000;
        }else{
            dur=0;
        }
        $(id).animate({scrollTop:h},dur);

    },
    animateEvent:function(id){
        var me=this;
        me.animateScroll(id);
        $(id).hover(function(){
            $(id).stop();
        },function(){
          // me.animateScroll(id);
        });
    },
    deepClone:function(obj){
        var newObj= obj instanceof Array?[]:{};
        for(var i in obj){
            newObj[i]=typeof obj[i]=='object'?
                this.deepClone(obj[i]):obj[i];
        }
        return newObj;
    },
    slideInit:function(con,ul){
        var $con=$(con);
        var conH=$con.find('.bd').height(),
            liH=$con.find('.item').height();
        if(liH>conH){
            $con.find('.item').after($con.find('.item').clone());
            $(con).slide({
                mainCell:ul,
                autoPlay:true,
                effect:"topMarquee",
                vis:1,
                interTime:50,
                trigger:"click",
                autoPage:true
            });
        }
    },
    updataByUrl:function (echartsIns,option) {
        var me=this;
        if(option.durs&&option.durs>0&&option.url){
            me.ajaxByUrl(option.url,function (val) {
                var type=echartsIns.chartType,newOpt={};
                switch(type){
                    case 'bar':

                        var id=echartsIns.getDom().id;
                        var index=me.getThisIndex(id);
                        val=me.barSort(val,index);
                        echartsIns.originData=val;
                        newOpt=me.getBarOption(val);
                        //me.barButtonInit(id,0);
                        //me.intervelBar(echartsIns,echartsIns.interdur);
                        break;
                    case 'bar2':
                        newOpt=me.getBar2Option(val);
                        break;
                    case 'tablesort':
                        echartsIns=me.echartSortInit(echartsIns.id,val);
                        break;
                    case 'pie':
                        newOpt=me.getPieIndexOption(val);
                        break;
                    case 'piering':
                        val.color=echartsIns.getOption().color;
                        newOpt=me.echartTowPieOpt(val);
                        break;
                    case 'treeinfo':
                        echartsIns=me.treeInfoInit(echartsIns.id,val);
                        break;
                }
                echartsIns.setOption(newOpt);
                setTimeout(function () {
                    me.updataByUrl(echartsIns,option);
                },option.durs);
            });
        }
    },
    ajaxByUrl:function (url,successCallback) {
        $.ajax({
            url: url,
            dataType: "json",
            success:function (val) {
                successCallback(val);
            },
            error:function () {
                console.log('请求异常');
            }
        });
    },
    updataFillByUrl:function (echartsIns,option) {
        var me=this;
        if(option.durs&&option.durs>0&&option.url){
            me.ajaxByUrl(option.url,function (val) {
                me.refreshLiquidFill(echartsIns,val);
                setTimeout(function () {
                    me.updataByUrl(echartsIns,option);
                },option.durs);
            });
        }
    },
    updataMapByUrl:function (echartsIns,option) {
        var me=this;
        if(option.durs&&option.durs>0&&option.url){
            me.ajaxByUrl(option.url,function (val) {
                var a=me.echartMapOpt(val);
                echartsIns.setOption(me.echartMapOpt(val));
                setTimeout(function () {
                    me.updataMapByUrl(echartsIns,option);
                },option.durs);
            });
        }
    },
    getArrTotal:function(arr,attr){
        if(arr){
            var l=arr.length,t=0;
            for(var i=0;i<l;i++){
                t+=arr[i][attr];
            }
            return t;
        }else{
            return 0;
        }
    },
    getPieSpilt:function(arr,spiltP){
        var t=this.getArrTotal(arr,'value'),spilt,
            l=arr.length;
        spiltP=spiltP||0.03;
        spilt=(spiltP*t)/(1-spiltP*l);
        return spilt;
    },
    sortData:function(data){
        data.sort(function(a,b){
            return b.value- a.value;
        });
        return data;
    },
    upadataTime:function(t,dur){
        var me=this;
        dur=dur||1000;
        setInterval(function(){
            me.setTime(t);
        },dur);
    },
    setTime:function(val){
        var date=new Date(val);
        if(date=='Invalid Date'){
            date=new Date();
        }
        var fdate=date.format('yyyy-MM-dd');
        var fdate1=date.format('W hh:mm:ss');
        var lastt='<span class="year">'+fdate+'</span><span class="hourse"> '+fdate1+'</span>'
        $('#lastTime').html(lastt);
    },
    hideLoad:function(){
        $('#load').remove();
        $('body').append($('#layout'));
        $('#layout').show();
    },
    showLoad:function(){
        if($('#load').length){
            $('#load').show();
        }else{
            var $load=$('<div class="loading" id="load"> <div class="load_icon"><svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="34px" height="40px" viewBox="0 0 24 30" style="enable-background:new 0 0 50 50;" xml:space="preserve">\n' +
                '    <rect x="0" y="12.5759" width="4" height="5.84811" fill="#fa9900">\n' +
                '      <animate attributeName="height" attributeType="XML" values="5;21;5" begin="0s" dur="0.6s" repeatCount="indefinite"></animate>\n' +
                '      <animate attributeName="y" attributeType="XML" values="13; 5; 13" begin="0s" dur="0.6s" repeatCount="indefinite"></animate>\n' +
                '    </rect>\n' +
                '    <rect x="10" y="9.42405" width="4" height="12.1519" fill="#fa9900">\n' +
                '      <animate attributeName="height" attributeType="XML" values="5;21;5" begin="0.15s" dur="0.6s" repeatCount="indefinite"></animate>\n' +
                '      <animate attributeName="y" attributeType="XML" values="13; 5; 13" begin="0.15s" dur="0.6s" repeatCount="indefinite"></animate>\n' +
                '    </rect>\n' +
                '    <rect x="20" y="5.42405" width="4" height="20.1519" fill="#fa9900">\n' +
                '      <animate attributeName="height" attributeType="XML" values="5;21;5" begin="0.3s" dur="0.6s" repeatCount="indefinite"></animate>\n' +
                '      <animate attributeName="y" attributeType="XML" values="13; 5; 13" begin="0.3s" dur="0.6s" repeatCount="indefinite"></animate>\n' +
                '    </rect>\n' +
                '  </svg></div> </div>');
            $('body').prepend('<style>.loading{width:100%;height:100%;position:absolute;left:0;top:0;z-index:1000;background:rgba(#0a1c47,1);}.loading .load_icon{position:relative;width:100px;height:100px;top:50%;margin-top:-50px;left:50%;margin-left:-50px;text-align:center;}.loading .load_icon svg{display:inline-block}}}</style>').prepend($load)
        }
    },
    loadingPage:function(callback,durs){
        var me=this;
        var newdurs=durs||1000;
        me.showLoad();
        setTimeout(function(){
            me.hideLoad();
            me.addTQ('fuzhou');
            //进入动画
            $('#frame_2').addClass('frameAnimate_2');
            $('#frame_1').addClass('frameAnimate_1');
            $('#frame_3').addClass('frameAnimate_3');
            setTimeout(function () {
                if(callback&&$.isFunction(callback)){
                    callback();
                }
            },100);

        },newdurs);
    },
    addTQ:function(city){
        var $rm=$('#layout .tab_wrapper .right-more');
        if($rm.length==0){
            $rm=$('<div class="right-more"></div>');
            $('#layout .tab_wrapper').append($rm);
        }
        $rm.html('<iframe width="145" scrolling="no" height="25" frameborder="0" allowtransparency="true" src="//i.tianqi.com/index.php?c=code&id=52&color=%23FFFFFF&icon=2&wind=1&num=1&site=14&py='+city+'"></iframe>');
    },
};

var hotChart=function(){};
hotChart.prototype={
    defaultOpt:{
        opacity:1,
        width:30,
        fontSize:22,
        bgColor:'#3b9cf6',
        color:'#e1e8fe',
        conWidth:'',
        position:[
            {x:0,y:0},
            {x:20,y:-10},
            {x:-20,y:30},
            {x:-40,y:30},
            {x:20,y:30},
            {x:-40,y:30},
            {x:-40,y:30},
            {x:-40,y:30},
            {x:-40,y:30}
        ],
        //default
        pre: [],
        data:[
            {name:'11',value:99},
            {name:'12',value:80},
            {name:'13',value:45},
            {name:'14',value:46},
            {name:'15',value:30}
        ]
    },
    opt:{
        color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{
            offset: 0,
            color: 'rgb(251, 118, 123)'
        }, {
            offset: 1,
            color: 'rgb(204, 46, 72)'
        }]),
        tooltip : {
            //trigger: 'item',
            formatter: "{b} : {c} 件"
        },
        animationDuration:1000
        //series:[]
    },
    fontSize:20,
    center:[
        [['50%', '50%'],['80%','25%'],['20%','20%'],['78%','77%'],['20%','69%']],
        [['50%', '50%'],['75%','22%'],['69%','79%'],['24%','23%'],['18%','69%']],
        [['50%', '50%'],['70%','28%'],['22%','25%'],['72%','72%'],['16%','69%']],
        [['50%', '50%'],['72%','22%'],['16%','69%'],['20%','25%'],['84%','77%']],
        [['50%', '50%'],['68%','22%'],['78%','72%'],['17%','30%'],['24%','75%']]
    ],
    tempN:[],
    init:function(id,data1){
        var data=this.deepClone(data1),allData= data.series[0].data,me=this;
        if(allData.length>0){
            allData=this.sortData(allData);
            var tepdata=this.getNumData(allData);
            data.series[0].data=tepdata;
            var l=data.series[0].data.length,maxNum=data.series[0].data[0]?data.series[0].data[0].value:0,
                ns=[],datas=[];
            for(var i=0;i<l;i++){
                var value=data.series[0].data[i]?data.series[0].data[i].value:0;
                if(value!=maxNum){
                    value=value*0.9;
                }
                var o=value/maxNum;
                if(o<0.4){
                    o=o*1.4;
                }
                datas.push(data.series[0].data[i]);
                var r=50*(o<0.4?0.4:(o>0.85?0.85:o));
                var seriesItem={
                    radius: r,
                    data:data.series[0].data[i],
                    label: {
                        fontSize:this.fontSize*(o<0.6?0.6:o)
                    }
                };
                ns.push(seriesItem);
            }

            //构造html
            $('#'+id).html(me.getHtml(ns));

            //设置大小
            me.resizeHot({id:id});
            $(window).resize(function(){
                me.resizeHot({id:id});
            });
        }else{

        }
        return {id:id,getDom:function(){},setOption:function () {
                
            }};
    },
    updataData:function(nsData){

    },
    resizeHot:function(obj){
        var id=obj.id,htmlwidth=$('#'+id).width(),htmlheight=$('#'+id).height();
        var thisw=htmlwidth*htmlwidth,maxw= (Math.sqrt(thisw/2)).toFixed(2);
        maxw=maxw*1.1;

        var sin=Math.sin(20/180*Math.PI);
        var R=((htmlheight-40)/2)/sin*2;
        maxw=R<=maxw?R:maxw;

        $('#'+id).find('.round2').css({
            'width':maxw,
            'height':maxw,
            'margin-left':-maxw/2,
            'margin-top':-maxw/2+10
        });
    },
    getHtml:function(nsData){
        var html='<div class="hot-orbit view-3D animate">';
        var center=nsData[0],
            d2=nsData[1],
            d3=nsData[2];
        var centerHtml='<div class="center"><div class="center_pos"  id="hot0"><div class="info"><span>'+center.data.name+'</span><br/><span>'+center.data.value+'</span></div></div></div>';


        var round= 2,roundNum=[2,4],index= 1,roundHtml='';
        for(var i=0;i<round;i++){
            roundHtml+='<div  class="orbit round'+(i+1)+'">';
            for(var j=0;j<roundNum[i];j++){
                var jIndex=j+1,
                    tempD=nsData[index];
                if(tempD){
                    roundHtml+='<div class="pos pos'+index+'"><div class="pie round1-pos1">' +
                    '<div class="info"><span>'+tempD.data.name+'</span><span class="value">'+tempD.data.value+'</span></div></div></div>';
                    index++;
                }
            }
            roundHtml+='</div>';
        }
        html+=centerHtml+roundHtml;
        return html;

    },
    sortData:function(data){
        data.sort(function(a,b){
            return b.value- a.value;
        });
        return data;
    },
    getNumData:function(data,num){
        var l,topDta=[],from=this.getFromTo(data.length),tempN;
        if(from){
            tempN=this.getRandNum(from.from,from.to);
            if(this.tempN.sort().toString()==tempN.sort().toString()){
                this.getNumData(data,num);
            }else{
                this.tempN=this.deepClone(tempN);
            }
            topDta.push(data[0]);
            topDta.push(data[1]);
            topDta.push(data[2]);
            topDta.push(data[tempN[0]]);
            topDta.push(data[tempN[1]]);
            topDta.push(data[tempN[2]]);
            topDta.push(data[tempN[3]]);
        }else{
            topDta.push(data[0]);
            topDta.push(data[1]);
            topDta.push(data[2]);
        }
        return topDta;
    },
    getFromTo:function(l){
        if(l<=3){
            return null;
        }else{
            return {
                from:3,
                to:l-1
            }
        }
    },
    getRandNum:function(from,to){
        var tempN=[],range=to-from,rand;
        var lastId;
        for(var i = 0; i < 4; i++) {
            rand=Math.random();
            var id=from + Math.round(rand * range);
            if(lastId == id){
                i--;
                continue;
            }
            lastId = id;
            tempN.push(id);
        }
        return tempN;
    },
    getCenter:function(){
        var num=Math.floor(Math.random()*5);
        var center=this.center[num];
        return center;
    },
    IntervalPie:function(id,dur,data){
        var i= 0,me=this,data1=data;
        var t=setInterval(function(){
            me.init(id,data1);
        },dur);
        var echartsInstance=echarts.getInstanceByDom(document.getElementById(id));
        if(echartsInstance){
            echartsInstance.inter=t;
            echartsInstance.dur=dur;
        }

    },
    isClass1:function(o){
        if(o===null) return "Null";
        if(o===undefined) return "Undefined";
        return Object.prototype.toString.call(o).slice(8,-1);
    },
    deepClone:function(obj){
        var newObj= obj instanceof Array?[]:{};
        for(var i in obj){
            newObj[i]=typeof obj[i]=='object'?
                this.deepClone(obj[i]):obj[i];
        }
        return newObj;
    },
    ajaxByUrl:function (url,successCallback) {
        $.ajax({
            url: url,
            dataType: "json",
            success:function (val) {
                successCallback(val);
            },
            error:function () {
                console.log('请求异常');
            }
        });
    },
    updataByUrl:function (echartsIns,option) {
        var me=this;
        var id=echartsIns.id;
        if(option.durs&&option.durs>0&&option.url){
            me.ajaxByUrl(option.url,function (val) {
                if( echartsIns.inter){
                    clearInterval(echartsIns.inter);
                    me.init(id,val);
                    var t=setInterval(function(){
                        echartsIns=me.init(id,val);
                    },echartsIns.dur);
                    echartsIns.inter=t;
                }else{
                    me.init(id,val);
                }
                setTimeout(function () {
                    me.updataByUrl(echartsIns,option);
                },option.durs);
            })
        }
    }
};

var divSelectFunction=function(){};
divSelectFunction.prototype={
  init:function(id,inpId,data,callback){
      var lis='',l=data.length;
      for(var i=0;i<l;i++){
          lis+='<li><a selectid="'+data[i].value+'" href="javascript:void(0);" class="">'+data[i].name+'</a></li>';
      }
      $(id+' cite').text(data[0].name);
      $(inpId).val(data[0].value);
      $(id+' ul').html(lis);
      $.divselect(id,inpId,function(value){
          callback();
      });
  }
};

var tool=function(){};
tool.prototype={
    timer:function(intDiff,day_ele,houre_ele,minute_ele,second_ele,callback){
        var setT=function(){
            var day = 0,
                hour = 0,
                minute = 0,
                second = 0;//时间默认值
            if (intDiff > 0) {
                //计算相关的天，小时，还有分钟，以及秒
                day = Math.floor(intDiff / (60 * 60 * 24));
                hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
                minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
                second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
            }
            if (minute <= 9) minute = '0' + minute;
            if (second <= 9) second = '0' + second;

            //var aa=$(houre_ele);
            if($(day_ele).length>0){
                $(day_ele).html(day + "");
            }
            if($(houre_ele).length>0){
                $(houre_ele).html('<s id="h"></s>' + hour + '');
            }
            if($(minute_ele).length>0){
                $(minute_ele).html('<s></s>' + minute + '');
            }
            if($(second_ele).length>0){
                $(second_ele).html('<s></s>' + second + '');
            }
            intDiff--;
        };
        setT();
        var s= window.setInterval(function () {
            setT();
        }, 1000);

        //循环函数，是时钟运动起来
        var tt=setInterval(function(){
            if($(second_ele).text() =='00'){
                clearInterval(s);
                clearInterval(tt);
                if(callback){
                    callback();
                }
            }
        },1000);
    }
};

function setHeight(fcon,hcon,hcon2){
    if($(window).width()>767){
        var h1=$(fcon).height();
        var h2=$(hcon).height();
        $(hcon2).css('height',h1-h2);

    }else{
        $(hcon2).css('height','');
        //table
        var thh=$('.table .table_hd').height();
        var wh=$(window).height();
        $('.table .table_bd').css('height',wh-thh-40);
    }

    //$('#Cheight').
}
function setMapHeight(fcon,hcon,hcon2){
    var h1=$(fcon).height();
    var h2=$(hcon).height();
    if($(window).width()<768){
        $(hcon2).css('height',h1-h2);

    }else{
        $(hcon2).css('height','');

    }
    $('#Cheight').css('height',(h1-220));
    $('#Cheight').parent().css('height',(h1-220)+57);

}
function menuInit(ele){
    $(ele).on('click',function(e){
        if($(this).hasClass('open')){
            $(this).removeClass('open')
        }else{
            $(this).addClass('open')
        }
        stopPropagation(e);
    });
    function stopPropagation(e) {
        if (e.stopPropagation) {
            e.stopPropagation();
        } else {
            e.cancelBubble = true;
        }
    }
    $(document).bind('click',function(){
        $(ele).removeClass('open');
    });
}
menuInit('.tab_wrapper .tab');
menuInit('.bar_menu');
function getData(url,data,isText) {
	var result ='';
	$.ajax({ 
        type : "post", 
        url : url, 
        data : data, 
        async : false, 
        success : function(data){ 
          result = data; 
        } 
        }); 
	if(result && !isText){result = JSON.parse(result)}
	return result;
}

var numDataFunction=function(){};
numDataFunction.prototype={
    countAllStateUpdate:function(numArr,conEle){
        $(conEle).find('.item-wrap').each(function(index,val){
            $(val).find('.numcon').text(numArr[index]);
        });
    },
    countAllNumInit:function(numArr,conEle){
        $(conEle).find('.item-wrap').each(function(index,val){
            var numColor= $(this).find('.numColor');
            numColor.attr('data-to',numArr[index]);
            numColor.countTo({
                formatter: function(b,a){return b.toFixed(0);}
            });
        });
    },
    countAllNumUpdate:function(numArr,conEle){
        $(conEle).find('.item-wrap').each(function(index,val){
            var numColor=$(val).find('.numColor');
            refreshCount(numColor,numArr[index]);
        });
    },
    countAllStateNumUpdate:function(objArr,conEle){

        var l=objArr.length,item_wraps=$(conEle).find('.item-wrap'),item_wrap;
        $(conEle).html('');
        for(var i=0;i<l;i++){
            item_wrap=item_wraps.eq(i);
            $(conEle).append(this.getAllStateNumHtml(objArr[i]));
        }
    },
    getAllStateNumHtml:function(obj){
        var stateArr=
        {
            1: {state: '01', className: 'wait'},
            2: {state: '02', className: 'ing'},
            3: {state: '03', className: 'busy'},
            4: {state: '04', className: 'out'}
        };

        var stime='';
        switch (obj.state) {
            case 1:
                stime = '<div class="stime">电话等待</div>';
                break;
            case 2:
                stime = '<div class="stime">通话中(00:02:35)</div>';
                break;
            case 3:
                stime = '<div class="stime">示忙</div>';
                break;
            case 4:
                stime = '<div class="stime">签出</div>';
                break;
        }
        var html='<div class="item-wrap" id="'+obj.id+'">'+
            '         <div class="num-item">'+
            '             <div class="icon">'+
            '                 <div class="iconfont bg-color-'+stateArr[obj.state].className+'">'+
            '                     <svg class="svg-icon">'+
            '                         <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icon-kefu"></use>'+
            '                     </svg>'+
            '                 </div>'+
            '             </div>'+
            '             <div class="text">'+
            '                 <div class="sid">'+obj.name+'</div>'+stime+
            '                 <div class="saft">坐席满意度：'+obj.saftP+'%</div>'+
            '             </div>'+
            '         </div>'+
            '     </div>';
        return html;
    },
    getNumDate:function(){
        var l=this.getRandom(25,30),objArr=[],obj,
            objCount1=0,objCount2=0,objCount3=0,objCount4=0;
        for(var i=0;i<l;i++){
            var state=this.getRandom(1,4);
            switch (state) {
                case 1:
                    objCount1++;//等待
                    break;
                case 2:
                    objCount2++;//通话
                    break;
                case 3:
                    objCount3++;//示忙
                    break;
                case 4:
                    objCount4++;//签出
                    break;
            }
            var saftP=this.getRandom(90,99);
            obj={
                id:'000'+(i+1),
                name:'000'+(i+1),
                state:state,
                saftP:saftP,
                time:200
            };
            objArr.push(obj);
        }
        var returnO={
            objArr:objArr,
            objCount:[objCount2,objCount3,objCount1,objCount4]
        };

        return returnO;

    },
    getRandom:function(minNum,maxNum){
        switch(arguments.length){
            case 1:
                return parseInt(Math.random()*minNum+1,10);
                break;
            case 2:
                return parseInt(Math.random()*(maxNum-minNum+1)+minNum,10);
                break;
            default:
                return 0;
                break;
        }
    }
};

var bMapFunction=function(opt){
    this.myGeo=new BMap.Geocoder();//geo
    this.bmap=opt.bmap;//map
    this.index=0;
    this.myChart=opt.myChart;//chart
    this.city=opt.city;//city
    this.title=opt.title||'';
    this.tiptitle=opt.tiptitle||'';
};
bMapFunction.prototype={
    markers:[],
    geoCoordMap:[],
    oldData:{},
    currentMiddleIndex:null,
    currentBigIndex:null,
    //地图数据填充及事件初始
    getMapOption:function(data){
        var me=this;
        me.oldData=me.deepClone(data);
        //me.myChart=me.myChart;

        //一级点
        if(data&&data.length>0){
            me.updataPointBig(data);

            var md=me.getMiddleData(data);
            me.updataPointMiddle(md);
            me.updataPointSmall(data);

            //左侧信息
            me.setBigDataInit(data);

            //地图加载完成事件
            me.bmap.addEventListener('tilesloaded',function(){
                me.myChart.hideLoading();
            });

            //地图缩放事件
            me.bmap.addEventListener('zoomend',function(a){
                var zoom=me.bmap.getZoom();
                if(zoom>14){
                    //三级
                    //console.log('zoomEnd'+zoom+s);
                    //隐藏大点，中点，显示小点
                    setTimeout(function(){
                        var op={
                            series:[
                                {
                                    symbolSize:0,
                                    tooltip:{
                                        extraCssText:'visibility:hidden;'
                                    },
                                    silent:true
                                },
                                {
                                    symbolSize:0,
                                    tooltip:{
                                        extraCssText:'visibility:hidden;'
                                    },
                                    silent:true
                                },
                                {
                                    symbolSize:8,
                                    silent:false
                                }
                            ]
                        };
                        try {
                            me.myChart.setOption(op);
                            me.myChart.resize();
                        } catch (e) {
                            me.errorFunction(e);
                        }
                    },10);

                }else if(zoom<11){
                    //一级
                    //隐藏小点,中点，显示大点
                    me.myChart.showLoading({
                        text:'加载中...',
                        color:'#0e2a68',
                        zlevel:11
                    });
                    setTimeout(function(){
                        //console.log('zoomEnd'+zoom+s);
                        var op={
                            series:[
                                {
                                    symbolSize:  function (val) {
                                        return me.getSize(val);
                                    },
                                    tooltip:{
                                        extraCssText:'visibility:visible;'
                                    },
                                    silent:false

                                },{
                                    symbolSize:0,
                                    silent:true
                                },{
                                    symbolSize:0,
                                    silent:true
                                }
                            ]
                        };
                        try {
                            me.myChart.setOption(op);

                        } catch (e) {
                            me.errorFunction(e);
                        }
                        //左侧更新
                        me.setBigDataInit(data,true);
                        me.myChart.hideLoading();
                    },10);

                }else{
                    //    二级
                    //    显示中点
                    setTimeout(function(){
                        var op={
                            series:[
                                {
                                    symbolSize:0,
                                    silent:true
                                },{
                                    symbolSize:  function (val) {
                                        return me.getSize(val);
                                    },
                                    tooltip:{
                                        extraCssText:'visibility:visible;'
                                    },
                                    silent:false

                                },{
                                    symbolSize:0,
                                    silent:true
                                }
                            ]
                        };
                        try {
                            me.myChart.setOption(op);

                        } catch (e) {
                            me.errorFunction(e);
                        }
                        me.myChart.hideLoading();
                    },10);
                    if(me.currentMiddleIndex!=null){
                        var thisop=me.myChart.getOption();
                        me.setMiddleDataInit(thisop.series[0].data[me.currentBigIndex],true);
                    }
                }
            });

            //一级点点击事件
            me.myChart.on('click',function(itemData){

                if(itemData.seriesIndex==0){
                    //一级点击
                    if(itemData.value[3]){
                        //加载中提示
                        me.myChart.showLoading({
                            text:'加载中...',
                            color:'#0e2a68',
                            zlevel:11
                        });

                        //me.updataPointSmall(data);

                        me.toMiddleMark(itemData);
                        me.currentBigIndex=itemData.dataIndex;
                    }
                }else if(itemData.seriesIndex==1){
                    //二级点击
                    if(itemData.value[3]){
                        //加载中提示
                        me.myChart.showLoading({
                            text:'加载中...',
                            color:'#0e2a68',
                            zlevel:11
                        });

                        //me.updataPointSmall(data);

                        me.toSmallMark(itemData.data);
                        me.currentMiddleIndex=itemData.dataIndex;
                    }

                }else if(itemData.seriesIndex==2){
                    //三级点击

                }

            });

            me.myChart.on('mouseover',function(itemData){
                var id;

                if(itemData.seriesIndex==0){
                    //一级点触发
                    id=itemData.data.dataId;
                    //二级点触发
                }else if(itemData.seriesIndex==1){
                    id=itemData.data.dataId;
                }else if(itemData.seriesIndex==2){
                    //三级点触发
                    id=itemData.data.value[2].dataId;
                }
                $('#Cheight li[data-id='+id+']').addClass('hover');
            });
            me.myChart.on('mouseout',function(itemData){
                var id;
                //一级点触发
                if(itemData.seriesIndex==0){
                    id=itemData.data.dataId;
                }else if(itemData.seriesIndex==1){
                    id=itemData.data.dataId;
                }else{
                    id=itemData.data.value[2].dataId;
                }
                $('#Cheight li[data-id='+id+']').removeClass('hover');
            });
        }
    },

    deepClone:function(obj){
        var newObj= obj instanceof Array?[]:{};
        for(var i in obj){
            newObj[i]=typeof obj[i]=='object'?
                this.deepClone(obj[i]):obj[i];
        }
        return newObj;
    },
    //数据微处理
    proData:function(data){
        var l=data.length;
        for(var i=0;i<l;i++){
            if(data[i].info){
                var tempData=data[i].info.info,
                    tl=tempData?tempData.length:0,
                    arr=new Object();
                for(var j=0;j<tl;j++){
                    var tempInfo=tempData[j];
                    if(!arr[tempInfo.type]){
                        arr[tempInfo.type]=1;
                    }else{
                        arr[tempInfo.type]=arr[tempInfo.type]+1;
                    }
                }
                data[i].info.classfiy=arr;
            }

        }
        return data;
    },
    //区域数据经纬格式化
    converDate:function(data){
        var res = [],index= 0,info;
        for (var i = 0; i < data.length; i++) {
            var geoCoord = data[i].geoCoord||[];
            data[i].dataId=i;
            if (geoCoord) {
                if(data[i].info){
                    info=data[i].info.info;
                    if(info){
                        for(var j=0;j<info.length;j++){
                            info[j].dataId=index;
                            index++;
                        }
                    }
                    var tepdata={
                        dataId:i,
                        key:data[i].key,
                        name: data[i].name,
                        value: geoCoord.concat(data[i].value,data[i].info)
                    };
                    res.push(tepdata);
                }

            }
        }
        //console.log(res);
        return res;
    },
    //详细数据经纬格式化
    converSmallDate:function(data){
        var res = [];
        for (var i = 0; i < data.length; i++) {
            var geoCoord = data[i].geoCoord||[];
            if (geoCoord) {
                var tepdata={
                    name: data[i].name,
                    value: geoCoord.concat(data[i])
                };
                res.push(tepdata);
            }
        }
        return res;
    },

    getSize:function(val){
        var size=parseInt(val[2])+10;
        var min=5,max=50;
        if(size<=min){
            size=min;
        }else if(size>max){
            size=max;
        }
        return size;
    },
    // 设置大点
    updataPointBig:function (data) {
        var me=this;
        var covBigData=me.converDate(data);
        var op1={
            //animation: true,
            bmap: {
                roam: true,
                mapStyle:{
                    styleJson:mapstyleJson
                }
            },
            tooltip : {
                trigger: 'item'
            },
            series: [{
                type:'effectScatter',
                coordinateSystem: 'bmap',
                rippleEffect:{
                    brushType:'fill',
                    period:3
                },
                itemStyle:{
                    normal:{
                        color:'#ff3d3d'
                    },
                    emphasis:{
                        color:'#ffdc68',
                        shadowColor:'#ffdc68'
                    }
                },

                symbolSize: function (val) {
                    return me.getSize(val);
                },
                data:covBigData,
                tooltip:{
                    formatter:function(params){
                        var classfiyHtml='',classfiy=params.data.value[3].classfiy;
                        for (var item in classfiy){
                            classfiyHtml +='<li><span>'+item+'：</span>'+classfiy[item]+'件</li>';
                        }
                        var html='<div class="map-tip1">' +
                            '<div class="count">共<span class="p-color">'+params.data.value[2]+'</span>件'+me.tiptitle+'</div>' +'<ul class="classfiy">'+classfiyHtml+'</ul>'+
                            '<div class="mapSite"><i></i>'+params.data.name+'周边</div>' +
                            '</div>';

                        return html;
                    },
                    padding:0,
                    position:'top'
                }
            }]
        };
        try {
            me.myChart.setOption(op1);
        } catch (e) {
            me.errorFunction(e);
        }
    },

    //设置中点
    updataPointMiddle:function(data){
        var me=this;
        var covMiddleData=me.converDate(data);
        var sop={
            series:[
                {
                    name:''
                },{
                    type:'effectScatter',
                    coordinateSystem: 'bmap',
                    rippleEffect:{
                        brushType:'fill',
                        period:3
                    },
                    itemStyle:{
                        normal:{
                            color:'#ff3d3d'
                        },
                        emphasis:{
                            color:'#ffdc68',
                            shadowColor:'#ffdc68'
                        }
                    },

                    symbolSize: 12,
                    data:covMiddleData,
                    tooltip:{
                        formatter:function(params){
                            var classfiyHtml='',classfiy=params.data.value[3].classfiy;
                            for (var item in classfiy){
                                classfiyHtml +='<li><span>'+item+'：</span>'+classfiy[item]+'件</li>';
                            }
                            var html='<div class="map-tip1">' +
                                '<div class="count">共<span class="p-color">'+params.data.value[2]+'</span>件'+me.tiptitle+'</div>' +'<ul class="classfiy">'+classfiyHtml+'</ul>'+
                                '<div class="mapSite"><i></i>'+params.data.name+'周边</div>' +
                                '</div>';

                            return html;
                        },
                        padding:0,
                        position:'top'
                    }
                }
            ]
        };
        try {
            me.myChart.setOption(sop);
        } catch (e) {
            me.errorFunction(e);
        }
    },
    // 设置小点
    updataPointSmall:function (data) {
        var me=this;
        //小点
        var cd=me.getSamllData(data);
        var covSmallData=me.converSmallDate(cd);
        var sop={
            series:[
                {
                    name:''
                },{
                    name:''
                },
                {
                    symbolSize:0,
                    type:'scatter',
                    coordinateSystem: 'bmap',
                    itemStyle:{
                        normal:{
                            color:'#ff3d3d'
                        },
                        emphasis:{
                            color:'#ffdc68',
                            shadowColor:'#ffdc68'
                        }
                    },
                    data:covSmallData,
                    tooltip:{
                        formatter:function(params){
                            var info=params.value[2];
                            var html='<div class="map-tip2">'+
                                '    <div class="tipWrap">'+
                                '        <div class="title">'+info.title+'</div>'+
                                '        <div class="con">'+info.conText+'</div>'+
                                '        <div class="info"><span>诉求类型：'+info.type+'</span><span class="fright">诉求时间：'+info.time+'</span></div>'+
                                '    </div>'+
                                '</div>';
                            return html;
                        },
                        padding:0,
                        position:'top'
                    }
                }
            ]
        };
        try {
            me.myChart.setOption(sop);
        } catch (e) {
            me.errorFunction(e);
        }
    },

    //列表滚动事件
    scrollEvent:function(faEle){
        var ch= $('#Cheight').height();
        var liH=$('#Cheight li').eq(0).height();
        var vis=Math.floor(ch/liH)+1;
        $(faEle).slide({
            mainCell:"ul",
            autoPage:true,
            effect:"topLoop",
            autoPlay:true,
            vis:vis
        });
    },
    //详细数据格式化1
    getSamllData:function(data){
        var l=data.length, j,cd=[];
        for(var i=0;i<l;i++){
            j=data[i].info.info.length;
            for(var k=0;k<j;k++){
                var tempd=data[i].info.info[k].info.info;
                if(tempd){
                    cd=cd.concat(tempd);
                }
            }
        }
        return cd;
    },

    //详细中点数据
    getMiddleData:function(data){
        var l=data.length,cd=data[0].info.info;
        for(var i=1;i<l;i++){
            if(data[i].info.info){
                cd=cd.concat(data[i].info.info);
            }
        }
        return cd;
    },

    //一级列表数据填充
    setBigDataInit:function(data,imporant){
        var me=this;
        data=data.sort(function(a,b){
            return b.value - a.value;
        });
        if(data){
            if(!$('#Cheight ul').hasClass('area_list')||imporant){
                showBodyLoad('<div class="load"></div>','#Cheight');
                var l =data.length,htmls=$('<ul class="area_list"></ul>');
                for(var i=0;i<l;i++){
                    htmls.append(this.getOneAreaHtml(data[i]));
                }
                $('#Cheight .bd').html(htmls);
                $('#listTitle').html('当天'+me.title+'<span class="sec">(共'+l+'条)</span>');

                //滚动事件
                me.scrollEvent('.dayList');

                //点击事件
                me.bigHtmlClick(l);
                hideBodyLoad('#Cheight');
            }
        }
    },
    //二级列表
    setMiddleDataInit:function(itemData,imporant){
        var me=this;
        var data =itemData.value[3].info;
        data=data.sort(function(a,b){
            return b.value - a.value;
        });
        if(data){
            if(!$('#Cheight ul').hasClass('area_list')||imporant){
                showBodyLoad('<div class="load"></div>','#Cheight');
                var l =data.length,htmls=$('<ul class="area_list"></ul>');
                for(var i=0;i<l;i++){
                    htmls.append(this.getOneAreaHtml(data[i]));
                }
                $('#Cheight .bd').html(htmls);
                $('#listTitle').html(itemData.name+me.title+'<span class="sec">(共'+l+'条)</span>');

                //滚动事件
                me.scrollEvent('.dayList');

                //点击事件
                me.middleHtmlClick(l);
                hideBodyLoad('#Cheight');
            }
        }
    },
    //三级信息列表数据填充
    setSmallDataInit:function(itemData,callback){
        var me=this;

        var info=itemData.value[3].info;
        info=info.sort(function(a,b){
            return b.value - a.value;
        });
        if(info){
            var l =info.length,htmls=$('<ul></ul>');
            for(var i=0;i<l;i++){
                htmls.append(this.getOneInfoHtml(info[i]));
            }
            $('#Cheight .bd').html(htmls);
            $('#listTitle').html(itemData.name+'&nbsp;&nbsp;'+me.title+'列表<span class="sec">(共'+l+'件)</span>');
            //滚动事件初始化
            me.scrollEvent('.dayList');

            me.smallHtmlClick(l);
            if(callback){
                callback();
            }
        }else{
            if(callback){
                callback();
            }
        }

    },
    //一级列表事件点击
    bigHtmlClick:function(l){
        var me=this;

        //区域点击
        $('#Cheight').find('li').on('click',function(){
            var option,index=$(this).attr('data-id');
            option=me.myChart.getOption();
            if(option.series[0]){
                me.toMiddleMark(option.series[0].data[index]);
                me.currentBigIndex=index;
            }
        });

        //区域定位
        $('#Cheight').find('li').hover(function(){
            var index=$(this).attr('data-id');

            me.myChart.dispatchAction({
                type:'showTip',
                dataIndex:index,
                seriesIndex:0
            });
            me.myChart.dispatchAction({
                type:'highlight',
                dataIndex:index,
                seriesIndex:0
            });
        },function(){
            me.myChart.dispatchAction({
                type:'hideTip',
                seriesIndex:0
            });
            me.myChart.dispatchAction({
                type:'downplay',
                seriesIndex:0
            });
        });
    },
    //二级列表事件点击
    middleHtmlClick:function(){
        var me=this;
        $('#Cheight').find('li').hover(function(){
            var index=$(this).attr('data-id');
            me.currentMiddleIndex=index;
            me.myChart.dispatchAction({
                type:'showTip',
                dataIndex:index,
                seriesIndex:1
            });
            me.myChart.dispatchAction({
                type:'highlight',
                dataIndex:index,
                seriesIndex:1
            });
        },function(){
            me.myChart.dispatchAction({
                type:'hideTip',
                seriesIndex:1
            });
            me.myChart.dispatchAction({
                type:'downplay',
                seriesIndex:1
            });
        }).on('click',function(){
            var option,index=$(this).attr('data-id');
            option=me.myChart.getOption();
            if(option.series[1]){
                me.toSmallMark(option.series[1].data[index]);
            }
        });
    },
    //三级列表事件点击
    smallHtmlClick:function(l){
        var me=this;
        //诉求件定位
        $('#Cheight').find('li').hover(function(){
            var index=$(this).attr('data-id');
            me.myChart.dispatchAction({
                type:'showTip',
                dataIndex:index,
                seriesIndex:2
            });
            me.myChart.dispatchAction({
                type:'highlight',
                dataIndex:index,
                seriesIndex:2
            });
        },function(){
            me.myChart.dispatchAction({
                type:'hideTip',
                seriesIndex:2
            });
            me.myChart.dispatchAction({
                type:'downplay',
                seriesIndex:2
            });
        }).on('click',function(){
            var index=$(this).attr('data-id');
            var op= me.myChart.getOption();
            var value=op.series[2].data[index].value;
            var center=new BMap.Point(value[0],value[1]);
            if(center.lng!=0||center.lat!=0){
                me.bmap.setCenter(center);
                me.myChart.dispatchAction({
                    type:'hideTip',
                    seriesIndex:1
                });
                me.myChart.dispatchAction({
                    type:'downplay',
                    seriesIndex:1
                });
            }

        });
    },

    //列表图标事件
    iconClick:function(fEle){
        var t;
        $(fEle).on('click',function(){
            clearTimeout(t);
            $('.dayList').toggleClass('hideList');
        });
        if($(window).width()<1024){

            $(fEle).trigger('click');
        }else{
            t=setTimeout(function(){
                $(fEle).trigger('click');
            },3000);
        }
    },
    //to小点
    toSmallMark:function(itemData){
        var me=this;
        //地图设置
        var centerGeo=itemData.value[3].info[0].geoCoord;
        var center=new BMap.Point(centerGeo[0],centerGeo[1]);
        me.bmap.centerAndZoom(center, 16);

        //文字列表
        me.setSmallDataInit(itemData);
    },
    //to中点
    toMiddleMark:function(itemData){
        var me=this;
        //地图设置
        var center=new BMap.Point(itemData.value[0],itemData.value[1]);
        me.bmap.centerAndZoom(center, 12);

        //文字列表
        me.setMiddleDataInit(itemData,true);
    },
    //其他方法
    getOneAreaHtml:function(areaItem){
        var l;
        var html='<li data-id="'+areaItem.dataId+'"> <div class="li_wrapper"> <div class="title">'+areaItem.name+'周边<span class="fright"><span class="p-color">'+areaItem.value+'</span>件</span></div> <div class="con">'+areaItem.key+'</div> </div> </li>';
        return html;
    },
    getOneInfoHtml:function(infoItem){
        var href='#';
        if(infoItem.href){
            href=infoItem.href;
        }
        var html='<li data-id="'+infoItem.dataId+'"><div class="li_wrapper"><a href="'+href+'"><div class="title">'+infoItem.title+'</div></a><div class="con">'+infoItem.conText+'</div><div class="info"><span>诉求类型：'+infoItem.type+'</span><span class="fright">诉求时间：'+infoItem.time+'</span></div></div></li>';
        return html;
    },
    countObj:function(obj) {
        var t = typeof obj;
        if (t == 'string') {
            return obj.length;
        } else if (t == 'object') {
            var n = 0;
            for (var i in obj) {
                n++;
            }
            return n;
        }
        return false;
    },
    //批量解析地址
    geocodeSearch:function(data,callback){
        var l=data.length,me=this,geoCoordMap=[],geoCoordMapL=0;
        this.geoCoordMap=[];
        for (var i=0; i < l; i++) {
            me.myGeo.getPoint(data[i].name, function(point,add){
                geoCoordMapL++;
                if (point) {
                    var name=add.address.toUpperCase();
                    var obj=[];
                    obj[name]=[point.lat,point.lng];
                    geoCoordMap[name]=[point.lng,point.lat];
                    me.geoCoordMap[name]=[point.lng,point.lat];
                }
                if(geoCoordMapL==l){
                    callback(geoCoordMap);
                }

            }, me.city);
        }
    },
    //地图工具初始化
    mapToolsInit:function(){
        var me=this;
        //设置地图缩放级别
        me.bmap.setMinZoom(5);

        //添加地图工具
        var top_right_navigation = new BMap.NavigationControl({
            anchor: BMAP_ANCHOR_TOP_RIGHT,
            type: BMAP_NAVIGATION_CONTROL_LARGE,
            showZoomInfo: true,
            offset:new BMap.Size(10,80)
        }); //右上角，仅包含平移和缩放按钮
        me.bmap.addControl(top_right_navigation);
    },
    //异常处理
    errorFunction:function(e){
        $('body').append('<div class="bodymask"><div class="center">请求异常，请刷新页面重试</div></div>');
    },
    // 数据刷新
    updatMap:function (data) {
        var me=this;
        if(!data.equals(me.oldData)){
            me.oldData=me.deepClone(data);
            me.myChart.setOption({
                animationDuration:0,
                animationDurationUpdate:300
            });

            //大点
            me.updataPointBig(data);
            me.setBigDataInit(data,true);

            //中点
            var md=me.getMiddleData(data);
            me.updataPointMiddle(md);

            //小点
            me.updataPointSmall(data);

            //地图事件缩放事件
            me.bmap.addEventListener('zoomend',function(a){
                var zoom=me.bmap.getZoom();
                if(zoom>9){

                }else{
                    me.setBigDataInit(data);
                }
            });
            me.bmap.centerAndZoom(me.city, 9);
        }

    },
    ajaxByUrl:function (url,successCallback) {
        $.ajax({
            url: url,
            dataType: "json",
            success:function (val) {
                successCallback(val);
            },
            error:function (msg) {
                console.log(msg.responseText);
            }
        });
    },
    updateMapByUrl:function (option) {
        var me=this;
        if(option.durs&&option.durs>0&&option.url){
            setTimeout(function () {
                me.ajaxByUrl(option.url,function (val) {
                    me.updatMap(val.data);
                    me.updateMapByUrl(option);
                });
            },option.durs);
        }
    }
};
function showBodyLoad(html,con){
    con=con||'body';
    var $bodymask=$(con).children('.bodymask');
    if($bodymask.length>0){
        $bodymask.html(html);
    }else{
        $(con).append('<div class="bodymask">'+html+'</div>');
    }
}

function hideBodyLoad(con){
    con=con||'body';
    var $bodymask=$(con).children('.bodymask');
    $bodymask.remove();
}
//时间格式
Date.prototype.format = function(fmt) {
    var weekday=["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
    var o = {
        "M+" : this.getMonth()+1,                 //月份
        "d+" : this.getDate(),                    //日
        "h+" : this.getHours(),                   //小时
        "m+" : this.getMinutes(),                 //分
        "s+" : this.getSeconds(),                 //秒
        "q+" : Math.floor((this.getMonth()+3)/3), //季度
        "S"  : this.getMilliseconds(),             //毫秒
        "W+": weekday[this.getDay()]
    };
    if(/(y+)/.test(fmt)) {
        fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
    }
    for(var k in o) {
        if(new RegExp("("+ k +")").test(fmt)){
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
        }
    }
    return fmt;
};

Array.prototype.equals = function (array) {
    // if the other array is a falsy value, return
    if (!array)
        return false;

    // compare lengths - can save a lot of time
    if (this.length !== array.length)
        return false;

    for (var i = 0, l = this.length; i < l; i++) {
        // Check if we have nested arrays
        if (this[i] instanceof Array && array[i] instanceof Array) {
            // recurse into the nested arrays
            if (!this[i].equals(array[i]))
                return false;
        }
        else if (this[i] !== array[i]) {
            // Warning - two different object instances will never be equal: {x:20} != {x:20}
            return false;
        }
    }
    return true;
};
var timingTask=function(fun,durs){
    if(typeof fun=='function'){
        fun();
        setTimeout(function(){
            timingTask(fun,durs);
        },durs);
    }

};


